feat!: unify mcp client payment wrapping into a single McpClient.wrap#526
Open
parvahuja wants to merge 2 commits into
Open
feat!: unify mcp client payment wrapping into a single McpClient.wrap#526parvahuja wants to merge 2 commits into
parvahuja wants to merge 2 commits into
Conversation
Contributor
Author
|
I can technically split this into two PRs if that makes it easier to review lmk... One for the MCP SDK client helpers and another for Tempo Accounts Provider-backed clients |
brendanjryan
reviewed
Jun 9, 2026
322fec5 to
47c1128
Compare
commit: |
parvahuja
commented
Jun 11, 2026
dea95d0 to
e6e1516
Compare
Collaborator
|
some comments -- can we just have a single |
added 2 commits
June 11, 2026 14:40
Renames src/mcp-sdk to src/mcp and adds the mppx/mcp/client and mppx/mcp/server entrypoints. The published mppx/mcp-sdk/client and mppx/mcp-sdk/server specifiers remain as aliases resolving to the same dist files, so existing imports keep working.
Collapses McpClient.wrap and wrapClient: wrap now mutates the client in place and returns the same reference, preserves the MCP SDK callTool(params, resultSchema?, options?) signature (context and a per-call onPaymentRequired ride in the options argument), handles payment challenges from both payment-required errors and tool-result metadata, accepts orderChallenges/paymentPreferences, and validates challenge payloads with the Challenge schema.
1d464df to
a6ea1ae
Compare
brendanjryan
approved these changes
Jun 11, 2026
| 'mppx': patch | ||
| --- | ||
|
|
||
| Added `wrapClient` to the new `mppx/mcp/client` entrypoint for adding automatic payment handling to an SDK-owned MCP client in place: the client is mutated and the same reference is returned, the MCP SDK `callTool(params, resultSchema?, options?)` signature is preserved (method `context` is passed via the options argument), and payment challenges returned as tool results via `org.paymentauth/payment-required` metadata are handled alongside payment-required errors. The MCP entrypoints moved to `mppx/mcp/client` and `mppx/mcp/server`; the `mppx/mcp-sdk/client` and `mppx/mcp-sdk/server` specifiers remain as aliases. |
Collaborator
There was a problem hiding this comment.
can we make this a bit shorter. we can just keep the first sentence before the :
| }) | ||
| }) | ||
|
|
||
| describe('McpClient.wrapClient', () => { |
Collaborator
There was a problem hiding this comment.
why not just wrap? `it's somewhat stuttering to do xClient.wrapClient
| type CallToolRequestOptions = Parameters<Client['callTool']>[2] | ||
| type PaymentRequiredData = NonNullable<core_Mcp.ErrorObject['data']> | ||
|
|
||
| const MPPX_MCP_CLIENT_WRAPPER = Symbol.for('mppx.mcp.client.wrapper') |
| import { serviceWorker } from './internal/html/serviceWorker.gen.js' | ||
|
|
||
| export { type McpSdk, mcpSdk } from '../mcp-sdk/server/Transport.js' | ||
| export { type McpSdk, mcpSdk } from '../mcp/server/Transport.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
McpClient.wrap(per review: one obvious API).wrapnow adds payment handling in place — the client is mutated and the same reference is returned, so surfaces that keep using the original client become payment-aware (e.g. when another SDK owns the reference, like Cloudflare Agents). Re-wrapping replaces the payment configuration instead of stacking.callToolkeeps the exact MCP SDK(params, resultSchema?, options?)signature;contextand a per-callonPaymentRequired(passnullto bypass the configured hook) ride in the third argument and are stripped before forwarding.-32042errors or as successful tool results carryingorg.paymentauth/payment-requiredmetadata; payment-required data is schema-validated. Config gainsorderChallengesandpaymentPreferences;methodsaccepts tuples.mppx/mcp/clientandmppx/mcp/server;mppx/mcp-sdk/*remain as aliases.Breaking (minor bump, per maintainer sign-off): the previous copy-semantics
wrapand its(params, options)signature are replaced by the in-place SDK-shape API above, and the approval-hook-as-first-argument overload from #522 moves to the options argument.Validation
pnpm check:ci,pnpm check:types,pnpm build; full vitest suite green in CI including localnet runtime shards.mppx/mcp-sdk/clientandmppx/mcp/clientresolve to the identical module.Companion PRs: tempoxyz/mpp#677 (docs), #540 + tempoxyz/accounts#645 (
wallet_authorizeChallenge).