Stripe Agent Toolkit MCP server

Integrates with Stripe's API to enable payment processing, customer management, and financial operations for e-commerce and billing workflows.
Back to servers
Setup instructions
Provider
Stripe
Release date
Feb 20, 2025
Language
TypeScript
Package
Stats
447.0K downloads
930 stars

The Stripe Agent Toolkit enables integration with Stripe APIs through function calling in various agent frameworks including OpenAI's Agent SDK, LangChain, CrewAI, Vercel's AI SDK, and Model Context Protocol (MCP). This toolkit supports both Python and TypeScript, making it easy to connect your AI agents with Stripe's payment processing capabilities.

Installation and Setup for MCP Server

Using the Remote MCP Server

Stripe hosts a remote MCP server that you can use directly:

https://mcp.stripe.com

Running a Local MCP Server

You can quickly run a local Stripe MCP server using npx:

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

Remember to replace YOUR_STRIPE_SECRET_KEY with your actual Stripe secret key from the Stripe Dashboard.

Setting Up Your Own MCP Server

For more control, you can set up a custom MCP server using TypeScript:

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);
});

Using the Toolkit in Python

Python Installation

Install the Python package using pip:

pip install stripe-agent-toolkit

Python Configuration

Configure the toolkit with your Stripe secret key:

from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit

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

Python Usage Example

The toolkit integrates easily with agent frameworks:

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()
)

Setting Context for Connected Accounts

For connected accounts, you can provide context values:

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

Using the Toolkit in TypeScript

TypeScript Installation

Install the TypeScript package using npm:

npm install @stripe/agent-toolkit

TypeScript Configuration

Configure the toolkit with your Stripe secret key:

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

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

TypeScript Usage with LangChain

Example integration with LangChain:

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

const tools = stripeAgentToolkit.getTools();

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

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

Metered Billing with Vercel AI SDK

For Vercel's AI SDK, you can implement metered billing:

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",
      },
    },
  }),
});

Supported API Methods

The toolkit supports various Stripe API operations including:

  • Creating payment links, products, prices, customers, and invoices
  • Managing subscriptions (create, update, cancel)
  • Handling refunds and disputes
  • Retrieving account balance
  • Working with coupons

Each of these methods maps directly to Stripe's API documentation for complete functionality.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "stripe-agent-toolkit" '{"command":"npx","args":["-y","@stripe/mcp","--tools=all"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "stripe-agent-toolkit": {
            "command": "npx",
            "args": [
                "-y",
                "@stripe/mcp",
                "--tools=all"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "stripe-agent-toolkit": {
            "command": "npx",
            "args": [
                "-y",
                "@stripe/mcp",
                "--tools=all"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later