ADK 的 Stripe MCP 工具¶
Supported in ADKPythonTypeScript
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",
# (Optional) Specify which tools to enable
# "--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}",
},
),
)
],
)
import { LlmAgent, MCPToolset } from "@google/adk";
const STRIPE_SECRET_KEY = "YOUR_STRIPE_SECRET_KEY";
const rootAgent = new LlmAgent({
model: "gemini-2.5-pro",
name: "stripe_agent",
instruction: "Help users manage their Stripe account",
tools: [
new MCPToolset({
type: "StdioConnectionParams",
serverParams: {
command: "npx",
args: [
"-y",
"@stripe/mcp",
"--tools=all",
// (Optional) Specify which tools to enable
// "--tools=customers.read,invoices.read,products.read",
],
env: {
STRIPE_SECRET_KEY: STRIPE_SECRET_KEY,
},
},
}),
],
});
export { rootAgent };
import { LlmAgent, MCPToolset } from "@google/adk";
const STRIPE_SECRET_KEY = "YOUR_STRIPE_SECRET_KEY";
const rootAgent = new LlmAgent({
model: "gemini-2.5-pro",
name: "stripe_agent",
instruction: "Help users manage their Stripe account",
tools: [
new MCPToolset({
type: "StreamableHTTPConnectionParams",
url: "https://mcp.stripe.com",
header: {
Authorization: `Bearer ${STRIPE_SECRET_KEY}`,
},
}),
],
});
export { rootAgent };
最佳实践
启用对工具操作的人工确认,并在将 Stripe MCP 服务器与其他 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 知识库 |