ST
OfficialFinance

Stripe MCP Server: Connect to Stripe API

Connect apps to Stripe using the MCP server to securely manage payments, transfers, and API interactions.

Overview

The Stripe MCP (Model Context Protocol) Server is a lightweight gateway that helps applications and AI agents interact with the Stripe API in a secure, auditable way. Instead of embedding secret keys or broad API credentials into client-side code or language models, the MCP server mediates requests, enforces scopes and policies, and performs the actual Stripe API calls on behalf of the caller. This reduces secrets exposure and gives teams control over which operations an automated agent can perform.

The server is part of the agent-toolkit ecosystem and is useful when you want to integrate LLM-powered assistants, backend services, or automation agents with Stripe for payments, refunds, transfers, and account management. It provides a consistent interface for registering “tools” (mapped operations or API surfaces) and invoking them with validated parameters, logging, and optional role-based restrictions.

Features

  • Secure mediation of Stripe API calls so clients never hold Stripe secret keys
  • Tool registration: declare permitted operations and parameter schemas
  • Scoped access: limit which tools or API operations an agent can call
  • Request validation and parameter sanitization
  • Audit logging of inbound requests and Stripe responses
  • Development and production modes (local testing vs. hosted deployment)
  • Optional Docker-ready configuration and environment-driven setup

Installation / Configuration

Prerequisites: Node 16+ (or the runtime specified by the repository), a Stripe account, and a Stripe secret key.

Clone the repository and install dependencies:

git clone https://github.com/stripe/agent-toolkit.git
cd agent-toolkit/mcp-server
npm install

Create a .env file to configure runtime variables (example):

# .env
STRIPE_API_KEY=sk_live_xxx
MCP_SERVER_PORT=8000
MCP_BASE_URL=http://localhost:8000
LOG_LEVEL=info

Start the server locally:

npm run build   # if TypeScript build step exists
npm start
# or for development
npm run dev

Run with Docker (example):

docker build -t stripe-mcp-server .
docker run -e STRIPE_API_KEY=sk_live_xxx -p 8000:8000 stripe-mcp-server

Configuration notes:

  • Keep the Stripe secret key in environment variables or a secrets manager; never check it into source control.
  • Use different keys for development and production.
  • Configure network access and TLS when exposing the server in production.

Available Tools / Resources

  • GitHub repository: https://github.com/stripe/agent-toolkit
  • Stripe API Reference: https://stripe.com/docs/api
  • Example manifests and tool templates are included in the agent-toolkit repo (look for MCP or tool configuration directories).
  • Audit logs and monitoring should be wired to your observability stack (console, file, or external service) depending on the deployment.

Example: Register and Call a Stripe Tool

A tool maps a named operation to specific Stripe API interactions (for example, create_payment_intent). Tool definitions typically include allowed parameters and validation rules. Below is a conceptual example of registering and calling a tool.

Register (example tool manifest, JSON):

{
  "name": "create_payment_intent",
  "description": "Create a PaymentIntent with amount and currency",
  "method": "POST",
  "path": "/v1/payment_intents",
  "allowed_params": ["amount", "currency", "payment_method_types", "metadata"]
}

Call the tool (example curl to MCP server):

curl -X POST "http://localhost:8000/tools/create_payment_intent" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method_types": ["card"],
    "metadata": {"order_id": "1234"}
  }'

The MCP server validates the payload against the tool schema, signs or injects the Stripe API key server-side, and forwards the request to Stripe. The server returns a sanitized response to the caller.

Use Cases

  • Automating merchant support workflows: An LLM assistant can create a refund for a customer when authorized. The assistant calls an MCP-registered refund tool; the server enforces scope so only refund-related parameters are permitted.
  • Payment orchestration in multi-tenant apps: For a platform creating PaymentIntents on behalf of connected accounts, the MCP server injects the appropriate account context and logs which caller performed the action.
  • Reconciliation and reporting: Scheduled agents can request balance summaries or list payouts. The MCP server centralizes credentials and logs all automated queries for audit.
  • Controlled transfers and payouts: When an automation needs to move funds between connected accounts, define narrow tools that only permit specific transfer amounts or metadata keys to reduce risk.
  • Secure prototyping with LLMs: During model-assisted development, allow local models or experimental bots to exercise a small set of Stripe operations without exposing production-level keys.

Operational Considerations

  • Audit and monitoring: Log all MCP operations, including caller identity, tool name, parameters, and Stripe responses.
  • Rate limiting: Apply rate limits to protect both your Stripe account and the MCP server.
  • Least privilege: Define minimal tool sets and parameter schemas to limit what automated agents can do.
  • Secrets management: Use a secrets manager (Vault, cloud KMS) for production Stripe keys and rotate keys regularly.

The MCP server provides a practical pattern for integrating AI agents and apps with Stripe while keeping credentials secure and operations auditable. For full implementation details and examples, refer to the agent-toolkit repository on GitHub.

Tags:finance