Cover image
Try Now
2025-04-14

轻巧的JavaScript客户端,用于与Stripe的模型上下文协议(MCP)服务器进行交互以创建付款链接。

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

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:

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

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

    Reviews

    3.4 (7)
    Avatar
    user_zsXcsUSi
    2025-04-24

    The stripe-mcp-client by MattMorgis is an outstanding tool for efficiently handling stripe transactions within a multi-client platform (mcp) environment. Its seamless integration and user-friendly interface make managing payments a breeze. Highly recommend this for anyone needing reliable and robust transaction processing.

    Avatar
    user_8tg648dr
    2025-04-24

    The stripe-mcp-client developed by MattMorgis is an exceptional tool that seamlessly integrates Stripe's payment functionalities with MCP applications. Its user-friendly interface and robust features have significantly streamlined my workflow. I highly recommend this client for anyone looking to optimize their payment processing system within an MCP environment.

    Avatar
    user_QK7vc58d
    2025-04-24

    The stripe-mcp-client by MattMorgis is an exceptional tool for anyone working with MCP applications. It's user-friendly and seamlessly integrates with Stripe, making transactions smooth and efficient. The documentation provided is clear and concise, which made the setup process straightforward. Highly recommended for developers looking to streamline payment processing.

    Avatar
    user_wb8Po9n7
    2025-04-24

    I have been using the stripe-mcp-client and I must say, it exceeded my expectations. The integration process was seamless and the functionality it offers is top-notch. Kudos to MattMorgis for developing such a user-friendly and efficient tool. Highly recommend it to anyone in need of a reliable mcp application.

    Avatar
    user_VdUz028z
    2025-04-24

    As a dedicated MCP application user, the stripe-mcp-client by MattMorgis has significantly streamlined my workflow. The integration is seamless and the functionality is top-notch. It handles all my payment processing needs efficiently and the user interface is very intuitive. Highly recommended for anyone looking for a reliable MCP client.

    Avatar
    user_d3J37zHd
    2025-04-24

    I've been using stripe-mcp-client from MattMorgis recently, and it's been a game-changer for managing my payment processes. The interface is user-friendly, and it integrates seamlessly with my existing setup. It's clear that a lot of thought has gone into the development of this product, making transactions smoother and more efficient. Highly recommend for anyone needing robust payment solutions!

    Avatar
    user_WhvxUvs9
    2025-04-24

    As a devoted user of MCP applications, stripe-mcp-client by MattMorgis has significantly impressed me. It's a seamless integration tool that effectively bridges the gap between various services. The user-friendly interface and robust performance make it an essential tool for anyone looking to streamline their operations. Highly recommended!