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
331.4K downloads
869 stars

The Stripe Agent Toolkit enables integration with Stripe APIs through function calling for various agent frameworks including MCP (Model Context Protocol). It works with both Python and TypeScript, built directly on the Stripe SDKs to provide streamlined access to Stripe's functionality.

Installation

Installing the MCP Server

You can run the Stripe MCP server directly using npx:

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

Make sure to replace YOUR_STRIPE_SECRET_KEY with your actual Stripe secret key from your Stripe Dashboard. Alternatively, you can set the STRIPE_SECRET_KEY in your environment variables.

Usage

Setting Up Your Own MCP Server

If you prefer to set up your own MCP server, you can do so with 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);
});

Python Integration

To install the Python package:

pip install stripe-agent-toolkit

Requirements:

  • Python 3.11+

Basic usage example:

from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit

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

With an agent framework:

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

TypeScript Integration

To install the TypeScript package:

npm install @stripe/agent-toolkit

Requirements:

  • Node 18+

Basic usage example:

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

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

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

Using Context for Connected Accounts

In both Python and TypeScript, you can provide context values as defaults when making requests:

Python:

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

TypeScript:

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

Metered Billing (Vercel AI SDK)

For Vercel's AI SDK, you can use middleware to submit billing events:

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 numerous Stripe API methods, including:

  • Creating and listing customers
  • Managing coupons, products, and prices
  • Creating payment links and invoices
  • Handling subscriptions
  • Processing refunds
  • Managing disputes

For the complete list of supported methods, refer to the official Stripe API documentation.

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