UNPKG

@chainbound/payflow-sdk

Version:
88 lines (85 loc) 3.1 kB
import { ServerOptions } from '@modelcontextprotocol/sdk/server/index.js'; import { McpServer, ToolCallback, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Implementation, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'; import { ZodRawShape } from 'zod'; /** * Options for a paid tool. */ type PaymentOptions = { /** * The price of the tool in the given asset. */ price: number; /** * The recipient of the payment. */ recipient: string; /** * The asset to use for the tool. */ asset?: string; /** * The network to settle the payment on. */ network?: number | string; }; type PayflowOptions = { x402?: { /** * The version of the x402 protocol to use. */ version?: number; /** * The API key ID for the Coinbase X402 facilitator. */ keyId?: string; /** * The API key secret for the Coinbase X402 facilitator. */ keySecret?: string; }; }; type PayflowMcpServerOptions = ServerOptions & PayflowOptions; /** * An extended MCP server that supports paid tools. */ declare class PayflowMcpServer extends McpServer { private readonly log; private readonly options; private readonly verify; private readonly settle; /** * Creates a new PayflowMcpServer instance. * * @param serverInfo - The server implementation details including name and version * @param options - Optional configuration for the server including x402 payment settings * * @example * ```typescript * const server = new PayflowMcpServer({ * name: 'my-paid-server', * version: '1.0.0' * }, { * x402: { * version: 1, * keyId: 'your-api-key-id', * keySecret: 'your-api-key-secret' * } * }); * ``` */ constructor(serverInfo: Implementation, options?: PayflowMcpServerOptions); private generateRequirements; private verifyPayment; private settlePayment; private createPaidCallback; paidTool(name: string, options: PaymentOptions, cb: ToolCallback): RegisteredTool; paidTool(name: string, description: string, options: PaymentOptions, cb: ToolCallback): RegisteredTool; paidTool<Args extends ZodRawShape>(name: string, options: PaymentOptions, paramsSchema: Args, cb: ToolCallback<Args>): RegisteredTool; paidTool<Args extends ZodRawShape>(name: string, description: string, options: PaymentOptions, paramsSchema: Args, cb: ToolCallback<Args>): RegisteredTool; paidTool<Args extends ZodRawShape>(name: string, options: PaymentOptions, paramsSchema: Args, annotations: ToolAnnotations, cb: ToolCallback<Args>): RegisteredTool; paidTool<Args extends ZodRawShape>(name: string, description: string, options: PaymentOptions, paramsSchema: Args, annotations: ToolAnnotations, cb: ToolCallback<Args>): RegisteredTool; private isZodRawShape; private isZodTypeLike; } export { PayflowMcpServer, type PayflowMcpServerOptions, type PaymentOptions };