Stripe AI MCP
Stripe AI is a one-stop shop with SDKs for building AI-powered products integrating Stripe's APIs and billing infrastructure. It supports Python and TypeScript, enabling seamless Stripe integration with popular agent frameworks and LLMs.
How to Install and Use Stripe AI MCP
If you want to build AI-powered products and connect them with Stripe’s APIs, the Stripe AI MCP is a powerful tool for you. It helps you use Stripe with popular AI agent frameworks and makes integration easier. Here’s a simple guide to installing and using Stripe AI MCP with examples.
Step 1: Installing Stripe AI MCP
Before you start, note that Stripe AI MCP supports different programming languages like Python and TypeScript. Choose the one that fits your project. Here's how to install the Stripe AI MCP toolkit in both languages.
For Python Users
To use Stripe AI MCP with Python, install the Stripe Agent Toolkit package from PyPI. This does not require downloading the source code unless you want to make changes.
Run this command in your terminal:
pip install stripe-agent-toolkit
Make sure you have Python 3.11 or newer installed on your computer.
For TypeScript / Node.js Users
If you prefer TypeScript or JavaScript, you can install the package from npm. Just run:
npm install @stripe/agent-toolkit
You need Node.js version 18 or higher for this.
Step 2: Setup Your Secret Key
Both Python and TypeScript require a secret key from your Stripe account. You get this key from the Stripe Dashboard under API keys. It’s needed to let the toolkit access your Stripe resources securely.
Step 3: Using the Toolkit in Python
After installation and getting your secret key, you can configure the toolkit in Python like this:
from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit
stripe_agent_toolkit = StripeAgentToolkit(
secret_key="sk_test_...",
configuration={
"actions": {
"payment_links": {
"create": True,
},
}
}
)
This code sets up Stripe AI MCP to create payment links, a common Stripe action.
To create an AI agent that uses Stripe, you can do:
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()
)
This agent will have Stripe tools available for handling payments and other Stripe operations.
Step 4: Using the Toolkit in TypeScript
TypeScript setup is similar but uses slightly different syntax.
First, import and initialize the toolkit with your secret key:
import { StripeAgentToolkit } from "@stripe/agent-toolkit/langchain";
const stripeAgentToolkit = new StripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {
actions: {
paymentLinks: {
create: true,
},
},
},
});
Next, connect it to your AI agent framework:
import { AgentExecutor, createStructuredChatAgent } from "langchain/agents";
const tools = stripeAgentToolkit.getTools();
const agent = await createStructuredChatAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({
agent,
tools,
});
This sets up an AI agent that can call Stripe APIs using the configured tools.
Step 5: Optional - Setting Context for Connected Accounts
If you want the agent to work with specific connected Stripe accounts, you can add a context setting during initialization.
For Python:
stripe_agent_toolkit = StripeAgentToolkit(
secret_key="sk_test_...",
configuration={
"context": {
"account": "acct_123"
}
}
)
For TypeScript:
const stripeAgentToolkit = new StripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {
context: {
account: "acct_123",
},
},
});
This tells the toolkit to use that account when making API calls.
Summary
To use Stripe AI MCP:
- Install the package (
pip install stripe-agent-toolkitfor Python, ornpm install @stripe/agent-toolkitfor TypeScript). - Get your secret API key from Stripe Dashboard.
- Initialize the StripeAgentToolkit with your key and set allowed actions.
- Configure your AI agent to use Stripe tools from the toolkit.
- Optionally, provide context for connected accounts to specify which Stripe account to use.
Stripe AI MCP makes it easy to add Stripe payment features to AI-powered applications with minimal coding. Follow these steps, and you'll be integrating Stripe in no time!