feat: add additional MCP server support with x402 batch payment example#434
feat: add additional MCP server support with x402 batch payment example#434plagtech wants to merge 6 commits into
Conversation
|
|
|
Reviewed the multi-MCP routing path from an agent-payment safety angle. The extension point is useful, but I would add a collision guard before this is exposed as a payment-tool pattern. Right now additional MCP servers are merged into if (this.additionalClient && this.additionalClient.hasTool(name)) {
return this.additionalClient.callTool(name, args);
}
return this.mcpClient.callTool(name, args, options);If an additional server exposes a tool with the same name as a Stripe core tool, it can shadow the Stripe tool at execution time. Depending on framework behavior, duplicate function/tool names may also produce invalid or ambiguous tool schemas for the model. For a payment toolkit, that is a risky default because an untrusted or misconfigured external MCP server could receive calls the developer expected to go to Stripe. Suggested fix before merge:
This is docs/code review only; I did not call external MCP servers or payment endpoints. |
|
Good catch — you're right that additional tools shouldn't be able to shadow core Stripe operations. Pushed a fix: Collision guard: MultiMcpClient.setReservedNames() receives all Stripe tool names before connecting additional servers. Any tool that shares a name with a Stripe tool is silently skipped with a console warning. |
|
Thanks for patching the collision case. I checked the new head and the guard looks directionally right: core Stripe names are reserved before additional MCP servers connect, and colliding external tools are skipped before routing can reach them. The current blocker appears to be CI/lint rather than the collision design itself. The failing TypeScript job is
I did not call any external MCP servers or payment endpoints. This is based on the GitHub Actions log for the failing TypeScript job on |
|
Thanks for the detailed breakdown — really appreciate you pulling the CI log. Pushing fixes now:
Will update shortly. |
|
Re-checked the current head after the formatting pass. The collision guard is still present conceptually, and all visible checks are now green: TypeScript, MCP, Python, and CLA. From the payment-tool routing angle, the important part is covered: an additional MCP server no longer appears able to shadow a core Stripe tool name before routing. That is the right default for this kind of extension point. I did not call external MCP servers or payment endpoints; this is source/CI review only. |
|
This is a high-fit thread for SATP rc.0 feedback because it combines MCP server extensibility with x402 payment examples and agent-side routing. If you are evaluating external protocol examples, @brainai/satp-client@0.1.0-rc.0 is published for opt-in testing: |
|
Thanks for flagging this. The additionalMcpServers pattern is designed to be protocol-agnostic — SATP would slot in the same way Spraay does. Happy to test the rc.0 client against the routing/collision guard if that helps validate the API shape. Would be a good second example of the extensibility working across different payment protocols. |
feat: Add support for additional MCP servers with x402 batch payment example
Problem
The Stripe Agent Toolkit currently connects exclusively to
mcp.stripe.comfor its tools. While the core Stripe tools handle individual operations well (create_payment_link, create_invoice, etc.), agents frequently need to perform batch operations — paying multiple contractors, splitting revenue across recipients, or processing bulk refunds.Today, an agent handling "pay these 5 contractors" must loop through individual
create_transfercalls. There's no batch primitive, and no way to extend the toolkit with additional payment capabilities from external providers.Solution
This PR adds support for additional MCP servers whose tools are merged with the core Stripe tools. This enables:
How it works
When the agent calls a tool:
mcp.stripe.comas beforeWhy x402
Stripe already supports the x402 payment protocol on Base. This PR extends that support into the agent toolkit by enabling x402-based batch payments — settling multiple transfers in a single on-chain transaction via USDC.
Changes
Core changes (backward compatible)
configuration.ts: AddedAdditionalMcpServertype andadditionalMcpServersconfig optionmulti-mcp-client.ts: New client that manages connections to additional MCP servers with tool routingtoolkit-core.ts: Extendedinitialize()to connect additional servers; addedrouteToolCall()for transparent routingFramework updates
openai/toolkit.ts: UpdatedhandleToolCall()to userouteToolCall()for correct routinglangchain/toolkit.ts: UpdatedStripeToolto route throughToolkitCoreinstead of directmcpClientaccessai-sdk/toolkit.ts: Updatedexecutecallbacks to userouteToolCall()Example & tests
examples/batch-payments/: Complete example showing x402 batch payments with Spraay Protocoltest/shared/multi-mcp-client.test.ts: Unit tests for the multi-MCP clientBackward compatibility
additionalMcpServersconfig is optional and defaults toundefinedTesting