Stripe MCP Client について
Stripe MCP Clientは、別のMCPサーバーからStripeのMCPサーバーを利用するためのJavaScriptラッパーです。支払いリンクの作成に特化し、MCP接続を自動管理します。
主な機能
- 01Stripe支払いリンクの作成
- 02カスタム作成オプションの指定
- 03連結アカウントへの対応
- 04MCP接続の自動管理
活用シーン
- 01MCPサーバーに支払いリンク作成機能を追加
- 02連結アカウント用の支払いリンク作成
MCP 対応
MCPクライアントとしてStripe MCPサーバーに接続し、支払いリンク作成メソッドを提供します。別のMCPサーバー内での利用を想定しています。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Stripe MCP クライアント
Stripe の Model Context Protocol(MCP)サーバーと連携して決済リンクを作成する、軽量な JavaScript クライアントです。このクライアントは、Stripe の決済サービスとの連携を可能にするために、独自の MCP サーバー内で使用するよう設計されています。
注記: このコードは Claude 3.7 Sonnet によって生成されました。動画
特長
- Stripe の決済リンクを作成するシンプルな API
- MCP クライアントを包む軽量なラッパー
- カスタムオプションと接続アカウントに対応
- MCP 接続を自動管理
インストール
npm install stripe-mcp-client
Node.js 16 以降がインストールされていることを確認してください。
依存関係
このパッケージは以下に依存します。
@modelcontextprotocol/sdk:MCP クライアントの実装用@stripe/mcp:Stripe MCP サーバー用(ピア依存関係)
使用方法
基本的な使用方法
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);
環境変数を使用する場合
// 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();
}
}
独自の MCP サーバー内で使用する場合
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);
設定オプション
StripeMcpClient コンストラクターは、以下のオプションを受け取ります。
| オプション | 型 | デフォルト | 説明 |
|---|---|---|---|
| apiKey | string | process.env.STRIPE_API_KEY | Stripe API キー |
| tools | string | 'paymentLinks.create' | 有効にする Stripe ツールのカンマ区切りリスト |
| stripeAccount | string | process.env.STRIPE_ACCOUNT | Stripe Connect アカウント ID(任意) |
| debug | boolean | false | デバッグログを有効にする |
API リファレンス
new StripeMcpClient(options)
新しいクライアントインスタンスを作成します。
client.connect()
Stripe MCP サーバーに接続します。必要に応じて、他のメソッドから自動的に呼び出されます。
client.createPaymentLink(options)
指定したオプションで新しい決済リンクを作成します。
パラメーター:
options:Stripe Payment Linkの作成パラメーターを含むオブジェクト
戻り値:
- 作成された決済リンクオブジェクトに解決される Promise
client.close()
Stripe MCP サーバーへの接続を閉じます。
テスト
npm test
ライセンス
MIT
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。