feat: add mcp client injection#526
Draft
parvahuja wants to merge 1 commit into
Draft
Conversation
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
| import type { Client } from '@modelcontextprotocol/sdk/client/index.js' | ||
| import { tempo } from 'mppx/client' | ||
| import type { Account } from 'viem' | ||
| import type { JsonRpcAccount } from 'viem/accounts' |
Collaborator
There was a problem hiding this comment.
can this file just be src/mcp?
you should be able to import via 'mppx/mcp/client'
| type CallToolRequestOptions = Parameters<Client['callTool']>[2] | ||
| type PaymentRequiredData = NonNullable<core_Mcp.ErrorObject['data']> | ||
|
|
||
| const MPPX_MCP_CLIENT_WRAPPER = Symbol.for('mppx.mcp.client.wrapper') |
| * await mcp.callTool({ name: 'premium_tool', arguments: {} }) | ||
| * ``` | ||
| */ | ||
| export function withMppClient< |
Collaborator
There was a problem hiding this comment.
can this just be wrapClient? MPP is a bit redundant
| const client extends Pick<Client, 'callTool'>, | ||
| const methods extends Methods, | ||
| >(client: client, config: withMppClient.Config<methods>): withMppClient.McpClient<client, methods> { | ||
| return inject(client, config) |
Collaborator
There was a problem hiding this comment.
what is the diff between inject and wrap?
| return Array.isArray(challenges) && challenges.length > 0 | ||
| } | ||
|
|
||
| function normalizeCallToolOptions<methods extends Methods>( |
Collaborator
There was a problem hiding this comment.
is there a more structured way to do these checks? this is pretty loose, which is maybe ok with strong table driven tests, but I feel like it can be simpler
| * This keeps mppx independent from the `accounts` package while allowing callers | ||
| * to pass an Accounts Provider directly to Tempo client methods. | ||
| */ | ||
| export type Provider = { |
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
withMppClient/McpClient.injectfor payment-aware MCP SDK clients while preserving the SDKcallToolshape.tempo.chargeand session methods.Validation
pnpm check:cipnpm check:typespnpm buildgit diff --checkVITE_TEMPO_NETWORK=none pnpm exec vp test --project node --testNamePattern 'McpClient|tempo\\.charge client|precompile client session'(48 passed; 3 MCP payment tests could not complete because local Tempo RPC atlocalhost:18545was unavailable)