Stripe¶
Stripe MCP 服务将你的 ADK 智能体连接到 Stripe 生态系统。此集成赋予你的智能体使用自然语言管理支付、客户、订阅和发票的能力,从而实现自动化的商务工作流和财务操作。
用例¶
-
自动化支付操作:通过对话指令创建支付链接、处理退款并列出支付意图。
-
简化发票流程:生成并定稿发票、添加行项目以及跟踪未付款项,而在无需离开开发环境的情况下完成。
-
获取业务洞察:查询账户余额、列出产品和价格,并在 Stripe 资源中进行搜索以制定数据驱动的决策。
前提条件¶
在智能体中使用¶
from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
from mcp import StdioServerParameters
STRIPE_SECRET_KEY = "YOUR_STRIPE_SECRET_KEY"
root_agent = Agent(
model="gemini-2.5-pro",
name="stripe_agent",
instruction="Help users manage their Stripe account",
tools=[
McpToolset(
connection_params=StdioConnectionParams(
server_params=StdioServerParameters(
command="npx",
args=[
"-y",
"@stripe/mcp",
"--tools=all",
# (可选) 指定要启用的工具
# "--tools=customers.read,invoices.read,products.read",
],
env={
"STRIPE_SECRET_KEY": STRIPE_SECRET_KEY,
}
),
timeout=30,
),
)
],
)
from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParams
STRIPE_SECRET_KEY = "YOUR_STRIPE_SECRET_KEY"
root_agent = Agent(
model="gemini-2.5-pro",
name="stripe_agent",
instruction="Help users manage their Stripe account",
tools=[
McpToolset(
connection_params=StreamableHTTPServerParams(
url="https://mcp.stripe.com",
headers={
"Authorization": f"Bearer {STRIPE_SECRET_KEY}",
},
),
)
],
)
最佳实践
启用人工确认工具操作的功能,并在与其他 MCP 服务一起使用 Stripe MCP 服务时务必谨慎,以降低提示词注入的风险。
可用工具¶
| 资源 | 工具 | API |
|---|---|---|
| 账户 | get_stripe_account_info |
检索账户信息 |
| 余额 | retrieve_balance |
检索余额 |
| 优惠券 | create_coupon |
创建优惠券 |
| 优惠券 | list_coupons |
列出优惠券 |
| 客户 | create_customer |
创建客户 |
| 客户 | list_customers |
列出客户 |
| 争议 | list_disputes |
列出争议 |
| 争议 | update_dispute |
更新争议 |
| 发票 | create_invoice |
创建发票 |
| 发票 | create_invoice_item |
创建发票项目 |
| 发票 | finalize_invoice |
定稿发票 |
| 发票 | list_invoices |
列出发票 |
| 支付链接 | create_payment_link |
创建支付链接 |
| 支付意图 | list_payment_intents |
列出支付意图 |
| 价格 | create_price |
创建价格 |
| 价格 | list_prices |
列出价格 |
| 产品 | create_product |
创建产品 |
| 产品 | list_products |
列出产品 |
| 退款 | create_refund |
创建退款 |
| 订阅 | cancel_subscription |
取消订阅 |
| 订阅 | list_subscriptions |
列出订阅 |
| 订阅 | update_subscription |
更新订阅 |
| 其他 | search_stripe_resources |
搜索 Stripe 资源 |
| 其他 | fetch_stripe_resources |
获取 Stripe 对象 |
| 其他 | search_stripe_documentation |
搜索 Stripe 知识库 |