stripe

stripe

Stripe 模型上下文协议服务器允许你通过函数调用与 Stripe API 集成。该协议支持各种工具来与不同的 Stripe 服务进行交互。

AI集成系统
访问服务器

README

Stripe Agent Toolkit

Stripe Agent Toolkit 使流行的代理框架(包括 OpenAI 的 Agent SDK、LangChain、CrewAI、Vercel 的 AI SDK 和模型上下文协议 (MCP))能够通过函数调用与 Stripe API 集成。该库并未涵盖整个 Stripe API。它包括对 Python 和 TypeScript 的支持,并且直接构建在 Stripe PythonNode SDK 之上。

下面包含基本说明,但有关更多信息,请参阅 PythonTypeScript 包。

Python

安装

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

pip install stripe-agent-toolkit

要求

  • Python 3.11+

用法

该库需要使用您帐户的密钥进行配置,该密钥可在您的 Stripe Dashboard 中找到。

from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit

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

该工具包可与 OpenAI 的 Agent SDK、LangChain 和 CrewAI 配合使用,并且可以作为工具列表传递。例如:

from agents import Agent

stripe_agent = Agent(
    name="Stripe Agent",
    instructions="You are an expert at integrating with Stripe",
    tools=stripe_agent_toolkit.get_tools()
)

OpenAI 的 Agent 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 Dashboard 中找到。此外,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",
    },
  },
});

计量计费

对于 Vercel 的 AI SDK,您可以使用中间件来提交使用情况的计费事件。所需的只是客户 ID 和要计费的输入/输出计量表。

import { StripeAgentToolkit } from "@stripe/agent-toolkit/ai-sdk";
import { openai } from "@ai-sdk/openai";
import {
  generateText,
  experimental_wrapLanguageModel as wrapLanguageModel,
} from "ai";

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

const model = wrapLanguageModel({
  model: openai("gpt-4o"),
  middleware: stripeAgentToolkit.middleware({
    billing: {
      customer: "cus_123",
      meters: {
        input: "input_tokens",
        output: "output_tokens",
      },
    },
  }),
});

模型上下文协议

Stripe Agent Toolkit 还支持 模型上下文协议 (MCP)

要使用 npx 运行 Stripe MCP 服务器,请使用以下命令:

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

YOUR_STRIPE_SECRET_KEY 替换为您实际的 Stripe 密钥。或者,您可以在环境变量中设置 STRIPE_SECRET_KEY。

或者,您可以设置自己的 MCP 服务器。例如:

import { StripeAgentToolkit } from "@stripe/agent-toolkit/modelcontextprotocol";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

const server = new StripeAgentToolkit({
  secretKey: process.env.STRIPE_SECRET_KEY!,
  configuration: {
    actions: {
      paymentLinks: {
        create: true,
      },
      products: {
        create: true,
      },
      prices: {
        create: true,
      },
    },
  },
});

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error("Stripe MCP Server running on stdio");
}

main().catch((error) => {
  console.error("Fatal error in main():", error);
  process.exit(1);
});

支持的 API 方法

推荐服务器

Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
AIO-MCP Server

AIO-MCP Server

🚀 集成了 AI 搜索、RAG 和多服务(GitLab/Jira/Confluence/YouTube)的一体化 MCP 服务器,旨在增强 AI 驱动的开发工作流程。来自 Folk。

精选
本地
https://github.com/Streen9/react-mcp

https://github.com/Streen9/react-mcp

react-mcp 与 Claude Desktop 集成,能够根据用户提示创建和修改 React 应用程序。

精选
本地
MCP Atlassian

MCP Atlassian

适用于 Atlassian Cloud 产品(Confluence 和 Jira)的 Model Context Protocol (MCP) 服务器。此集成专为 Atlassian Cloud 实例设计,不支持 Atlassian Server 或 Data Center 部署。

精选
any-chat-completions-mcp

any-chat-completions-mcp

将 Claude 与任何 OpenAI SDK 兼容的聊天完成 API 集成 - OpenAI、Perplexity、Groq、xAI、PyroPrompts 等。

精选
MySQL MCP Server

MySQL MCP Server

允许人工智能助手通过受控界面列出表格、读取数据和执行 SQL 查询,从而使数据库探索和分析更安全、更有条理。

精选
browser-use MCP server

browser-use MCP server

一个由人工智能驱动的浏览器自动化服务器,它实现了模型上下文协议,从而能够使用自然语言控制网页浏览器,以执行诸如导航、表单填写和视觉交互等任务。

精选
mcp-codex-keeper

mcp-codex-keeper

作为开发知识的守护者,为 AI 助手提供精心策划的最新文档和最佳实践访问权限。

精选