- Stripe MCP Client
Stripe MCP Client
A lightweight JavaScript client for interacting with Stripe's Model Context Protocol (MCP) server to create payment links.
Content
Stripe MCP Client
A lightweight JavaScript client for interacting with Stripe's Model Context Protocol (MCP) server to create payment links. This client is designed to be used inside your own MCP server to enable integration with Stripe's payment services.
Note: This code was generated by Claude 3.7 Sonnet. Video
Features
- Simple API for creating Stripe payment links
- Lightweight wrapper around the MCP client
- Supports custom options and connected accounts
- Automatic management of the MCP connection
Installation
npm install stripe-mcp-client
Make sure you have Node.js 16+ installed.
Dependencies
This package depends on:
@modelcontextprotocol/sdk: For the MCP client implementation@stripe/mcp: For the Stripe MCP server (peer dependency)
Usage
Basic Usage
import StripeMcpClient from 'stripe-mcp-client';
async function createPaymentLink() {
// Initialize the client
const client = new StripeMcpClient({
apiKey: 'your_stripe_api_key', // Or set STRIPE_API_KEY env var
debug: true, // Optional: Enable debug logging
});
try {
// Connect to the Stripe MCP server
await client.connect();
// Create a payment link
const paymentLink = await client.createPaymentLink({
line_items: [
{
price: 'price_123', // Your Stripe price ID
quantity: 1,
},
],
after_completion: {
type: 'redirect',
redirect: {
url: 'https://example.com/thank-you',
},
},
});
console.log(`Payment link created: ${paymentLink.url}`);
return paymentLink;
} finally {
// Always close the connection when done
await client.close();
}
}
createPaymentLink().catch(console.error);
Using with Environment Variables
// Set in your environment: STRIPE_API_KEY, STRIPE_ACCOUNT (optional)
import StripeMcpClient from 'stripe-mcp-client';
async function createPaymentLink() {
const client = new StripeMcpClient();
try {
await client.connect();
const paymentLink = await client.createPaymentLink({
line_items: [{price: 'price_123', quantity: 1}],
});
return paymentLink;
} finally {
await client.close();
}
}
Using Within Your Own MCP Server
import {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import StripeMcpClient from 'stripe-mcp-client';
import {z} from 'zod';
// Create your MCP server
const server = new McpServer({
name: 'My Payment Server',
version: '1.0.0',
});
// Add a tool that creates Stripe payment links
server.tool(
'create_payment_link',
'Create a Stripe payment link for checkout',
{
product_name: z.string().describe('Name of the product'),
price_amount: z.number().describe('Price amount in cents'),
currency: z
.string()
.default('usd')
.describe('Currency code (default: usd)'),
},
async ({product_name, price_amount, currency}) => {
// Initialize the Stripe MCP client
const stripeClient = new StripeMcpClient();
try {
await stripeClient.connect();
// Create a payment link using the Stripe MCP server
const paymentLink = await stripeClient.createPaymentLink({
line_items: [
{
price_data: {
currency: currency,
product_data: {
name: product_name,
},
unit_amount: price_amount,
},
quantity: 1,
},
],
});
return {
content: [
{
type: 'text',
text: JSON.stringify({
payment_link_url: paymentLink.url,
payment_link_id: paymentLink.id,
}),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text',
text: `Error creating payment link: ${error.message}`,
},
],
isError: true,
};
} finally {
await stripeClient.close();
}
}
);
// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);
Configuration Options
The StripeMcpClient constructor accepts the following options:
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | process.env.STRIPE_API_KEY | Your Stripe API key |
| tools | string | 'paymentLinks.create' | Comma-separated list of Stripe tools to enable |
| stripeAccount | string | process.env.STRIPE_ACCOUNT | Optional Stripe Connect account ID |
| debug | boolean | false | Enable debug logging |
API Reference
new StripeMcpClient(options)
Creates a new client instance.
client.connect()
Connects to the Stripe MCP server. Called automatically by other methods if needed.
client.createPaymentLink(options)
Creates a new payment link with the specified options.
Parameters:
options: An object containing the Stripe Payment Link creation parameters
Returns:
- A Promise that resolves to the created payment link object
client.close()
Closes the connection to the Stripe MCP server.
Testing
npm test
License
MIT
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Amap Maps高德地图官方 MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
CursorThe AI Code Editor
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Playwright McpPlaywright MCP server
ChatWiseThe second fastest AI chatbot™
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.