关于 Stripe MCP Client
Stripe MCP Client 是一个 JavaScript 封装库,可在其他 MCP 服务中调用 Stripe 的 MCP 服务。它专注于创建支付链接,并自动管理 MCP 连接。
主要功能
- 01创建 Stripe 支付链接
- 02接受自定义创建选项
- 03支持关联账户
- 04自动管理 MCP 连接
适用场景
- 01为 MCP 服务添加支付链接创建功能
- 02为关联账户创建支付链接
MCP 相关
它作为 MCP 客户端连接 Stripe MCP 服务,并提供创建支付链接的方法。该库面向在其他 MCP 服务中使用。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
暂未收录安装方式
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Stripe MCP Client
一个轻量级 JavaScript 客户端,用于与 Stripe 的 Model Context Protocol(MCP)服务交互并创建付款链接。此客户端旨在用于你自己的 MCP 服务中,以便集成 Stripe 的付款服务。
注意: 此代码由 Claude 3.7 Sonnet 生成。视频
功能
- 用于创建 Stripe 付款链接的简单 API
- MCP 客户端的轻量级封装
- 支持自定义选项和关联账户
- 自动管理 MCP 连接
安装
npm install stripe-mcp-client
请确保已安装 Node.js 16+。
依赖项
此软件包依赖于:
@modelcontextprotocol/sdk:用于 MCP 客户端实现@stripe/mcp:用于 Stripe MCP 服务(对等依赖项)
用法
基本用法
import StripeMcpClient from 'stripe-mcp-client';
async function createPaymentLink() {
// Initialize the client
const client = new StripeMcpClient({
apiKey: 'your_stripe_api_key', // Or set STRIPE_API_KEY env var
debug: true, // Optional: Enable debug logging
});
try {
// Connect to the Stripe MCP server
await client.connect();
// Create a payment link
const paymentLink = await client.createPaymentLink({
line_items: [
{
price: 'price_123', // Your Stripe price ID
quantity: 1,
},
],
after_completion: {
type: 'redirect',
redirect: {
url: 'https://example.com/thank-you',
},
},
});
console.log(`Payment link created: ${paymentLink.url}`);
return paymentLink;
} finally {
// Always close the connection when done
await client.close();
}
}
createPaymentLink().catch(console.error);
使用环境变量
// Set in your environment: STRIPE_API_KEY, STRIPE_ACCOUNT (optional)
import StripeMcpClient from 'stripe-mcp-client';
async function createPaymentLink() {
const client = new StripeMcpClient();
try {
await client.connect();
const paymentLink = await client.createPaymentLink({
line_items: [{price: 'price_123', quantity: 1}],
});
return paymentLink;
} finally {
await client.close();
}
}
在你自己的 MCP 服务中使用
import {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import StripeMcpClient from 'stripe-mcp-client';
import {z} from 'zod';
// Create your MCP server
const server = new McpServer({
name: 'My Payment Server',
version: '1.0.0',
});
// Add a tool that creates Stripe payment links
server.tool(
'create_payment_link',
'Create a Stripe payment link for checkout',
{
product_name: z.string().describe('Name of the product'),
price_amount: z.number().describe('Price amount in cents'),
currency: z
.string()
.default('usd')
.describe('Currency code (default: usd)'),
},
async ({product_name, price_amount, currency}) => {
// Initialize the Stripe MCP client
const stripeClient = new StripeMcpClient();
try {
await stripeClient.connect();
// Create a payment link using the Stripe MCP server
const paymentLink = await stripeClient.createPaymentLink({
line_items: [
{
price_data: {
currency: currency,
product_data: {
name: product_name,
},
unit_amount: price_amount,
},
quantity: 1,
},
],
});
return {
content: [
{
type: 'text',
text: JSON.stringify({
payment_link_url: paymentLink.url,
payment_link_id: paymentLink.id,
}),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text',
text: `Error creating payment link: ${error.message}`,
},
],
isError: true,
};
} finally {
await stripeClient.close();
}
}
);
// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);
配置选项
StripeMcpClient 构造函数接受以下选项:
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| apiKey | string | process.env.STRIPE_API_KEY | 你的 Stripe API 密钥 |
| tools | string | 'paymentLinks.create' | 要启用的 Stripe 工具列表,以逗号分隔 |
| stripeAccount | string | process.env.STRIPE_ACCOUNT | 可选的 Stripe Connect 账户 ID |
| debug | boolean | false | 启用调试日志 |
API 参考
new StripeMcpClient(options)
创建一个新的客户端实例。
client.connect()
连接到 Stripe MCP 服务。如果需要,其他方法会自动调用此方法。
client.createPaymentLink(options)
使用指定选项创建新的付款链接。
参数:
options:包含 Stripe 付款链接创建参数 的对象
返回值:
- 一个 Promise,解析为已创建的付款链接对象
client.close()
关闭与 Stripe MCP 服务的连接。
测试
npm test
许可证
MIT
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。