article
README
🚀 MCP Stripe 服务器
MCP Stripe 服务器是一个与 Stripe 集成的 Model Context Protocol (MCP) 服务器实现,可处理支付、客户和退款等业务。它提供了结构化的 API,能安全地管理财务交易,为用户提供便捷、安全的支付管理体验。
🚀 快速开始
需求
- Python 3.8+
- MCP SDK 0.1.0+
- Stripe Python SDK
- dotenv
安装
使用 Smithery 安装
可通过 Smithery 自动安装 Claude Desktop 的 Stripe 服务器,命令如下:
npx -y @smithery/cli install @atharvagupta2003/mcp-stripe --client claude
安装依赖项
python -m venv venv
source venv/bin/activate # 在 macOS/Linux 上
venv\Scripts\activate # 在 Windows 上
pip install -e .
配置
在 .env 文件中设置环境变量:
STRIPE_API_KEY=your_stripe_secret_key
Claude Desktop
将服务器配置添加到您的 Claude Desktop 配置中:
- Windows:C:\Users<username>\AppData\Roaming\Claude\claude_desktop_config.json
- MacOS:~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"stripe": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/src",
"run",
"server.py"
]
}
}
}
启动服务器
uv run src/server.py
✨ 主要特性
- 安全支付:与 Stripe 集成以实现稳健的支付处理。
- 审计日志:记录所有 Stripe 交易。
- 错误处理:全面的错误处理,带有清晰的消息。
- MCP 集成:支持兼容 MCP 的工具和资源列表。
📦 安装指南
使用 Smithery 安装
通过 Smithery 自动安装 Claude Desktop 的 Stripe 服务器:
npx -y @smithery/cli install @atharvagupta2003/mcp-stripe --client claude
安装依赖项
python -m venv venv
source venv/bin/activate # 在 macOS/Linux 上
venv\Scripts\activate # 在 Windows 上
pip install -e .
配置
在 .env 文件中设置环境变量:
STRIPE_API_KEY=your_stripe_secret_key
Claude Desktop
将服务器配置添加到您的 Claude Desktop 配置中: Windows:C:\Users<username>\AppData\Roaming\Claude\claude_desktop_config.json MacOS:~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"stripe": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/src",
"run",
"server.py"
]
}
}
}
💻 使用示例
基础用法
MCP 示例命令
创建客户
{
"tool": "customer_create",
"arguments": {
"email": "customer@example.com",
"name": "John Doe"
}
}
检索客户
{
"tool": "customer_retrieve",
"arguments": {}
}
更新客户
{
"tool": "customer_update",
"arguments": {
"id": "customer_id",
"email": "new_email@example.com"
}
}
支付意图创建
uv payment_intent_create --amount 100 --currency usd
费用列表
uv charge_list
创建退款
{
"tool": "refund_create",
"arguments": {
"charge_id": "charge_123"
}
}
📚 详细文档
组件
资源
该服务器提供所有 Stripe 操作的审计日志记录:
- 存储客户、支付和退款操作的审计日志。
- 支持结构化日志以提高可追溯性。
- 使用 MCP 资源端点检索审核数据。
工具
该服务器实现 Stripe API 操作,包括:
客户管理
- customer_create:创建新客户。
- customer_retrieve:检索客户的详细信息。
- customer_update:更新客户信息。
支付操作
- payment_intent_create:为处理支付创建付款意图。
- charge_list:列出最近的费用。
退款操作
- refund_create:为一笔收费创建退款。
🔧 技术细节
错误处理
- 参数错误:当传递无效参数时,服务器返回 400 错误。
- 权限错误:未授权访问资源时,返回 401 错误。
- 内部错误:服务器在处理请求时出现内部错误时,返回 500 错误。
📄 许可证
保留所有权利。禁止未经授权的复制或分发。
扫码联系在线客服