返回市场
代理工具包

代理工具包

作者:stripe1124 星标更新:2025-11-20

项目介绍

【技术文档摘要】: Hero GIF

Stripe AI

此仓库是构建基于Stripe的AI驱动产品和服务的一站式商店。

它包含一系列SDK,帮助您将Stripe与LLMs和代理框架集成,包括:

模型上下文协议 (MCP)

Stripe在https://mcp.stripe.com托管了一个远程MCP服务器。这允许通过OAuth进行安全的MCP客户端访问。查看文档这里

Stripe代理工具包还在模型上下文协议 (MCP)格式中暴露了工具。或者,要使用npx运行本地Stripe MCP服务器,请使用以下命令:

npx -y @stripe/mcp --tools=all --api-key=YOUR_STRIPE_SECRET_KEY

详情请参阅MCP

代理工具包

Stripe的代理工具包使流行的代理框架(包括OpenAI的代理SDK、LangChain、CrewAI和Vercel的AI SDK)能够通过函数调用与Stripe API集成。该库并不涵盖整个Stripe API。它支持Python和TypeScript,并直接建立在Stripe的PythonNode SDK之上。

下面提供了基本说明,但请参阅PythonTypeScript包以获取更多信息。

Python

安装

除非您想修改该包,否则不需要此源代码。如果您只是想使用该包,请运行:

pip install stripe-agent-toolkit
要求
  • Python 3.11+

使用

库需要使用您的账户密钥进行配置,该密钥可在您的Stripe仪表板中找到。

from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit

stripe_agent_toolkit = StripeAgentToolkit(
    secret_key="sk_test_...",
    configuration={
        "actions": {
            "payment_links": {
                "create": True,
            },
        }
    },
)

该工具包与OpenAI的代理SDK、LangChain和CrewAI兼容,并且可以作为工具列表传递。例如:

from agents import Agent

stripe_agent = Agent(
    name="Stripe Agent",
    instructions="您是集成Stripe方面的专家",
    tools=stripe_agent_toolkit.get_tools()
)

有关OpenAI的代理SDK、LangChain和CrewAI的示例,请参见/examples

上下文

在某些情况下,您可能希望提供默认值,以便在请求时使用。当前,account上下文值允许您为您的连接账户进行API调用。

stripe_agent_toolkit = StripeAgentToolkit(
    secret_key="sk_test_...",
    configuration={
        "context": {
            "account": "acct_123"
        }
    }
)

TypeScript

安装

除非您想修改该包,否则不需要此源代码。如果您只是想使用该包,请运行:

npm install @stripe/agent-toolkit
要求
  • Node 18+

使用

库需要使用您的账户密钥进行配置,该密钥可在您的Stripe仪表板中找到。此外,configuration允许您指定可以使用工具包执行的操作类型。

import { StripeAgentToolkit } from "@stripe/agent-toolkit/langchain";

const stripeAgentToolkit = new StripeAgentToolkit({
  secretKey: process.env.STRIPE_SECRET_KEY!,
  configuration: {
    actions: {
      paymentLinks: {
        create: true,
      },
    },
  },
});
工具

该工具包与LangChain和Vercel的AI SDK兼容,并且可以作为工具列表传递。例如:

import { AgentExecutor, createStructuredChatAgent } from "langchain/agents";

const tools = stripeAgentToolkit.getTools();

const agent = await createStructuredChatAgent({
  llm,
  tools,
  prompt,
});

const agentExecutor = new AgentExecutor({
  agent,
  tools,
});
上下文

在某些情况下,您可能希望提供默认值,以便在请求时使用。当前,account上下文值允许您为您的连接账户进行API调用。

const stripeAgentToolkit = new StripeAgentToolkit({
  secretKey: process.env.STRIPE_SECRET_KEY!,
  configuration: {
    context: {
      account: "acct_123",
    },
  },
});

支持的API方法

请参阅Stripe MCP文档以获取支持的方法列表。

许可证

MIT