Proxy MCP client name in local stdio server User-Agent#304
Open
mvanhorn wants to merge 1 commit intostripe:mainfrom
Open
Proxy MCP client name in local stdio server User-Agent#304mvanhorn wants to merge 1 commit intostripe:mainfrom
mvanhorn wants to merge 1 commit intostripe:mainfrom
Conversation
Extract the client name from the MCP initialize request and include it in the User-Agent header sent to mcp.stripe.com. When a client like Cursor or Claude Desktop connects, the User-Agent now reads "stripe-mcp-local/0.3.1 (cursor)" instead of just "stripe-mcp-local/0.3.1". The HTTP transport creation is deferred until the first stdio message arrives, so the client name from the initialize request can be captured before any HTTP requests are made. Fixes stripe#250
|
|
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
Extracts the MCP client name from the
initializerequest and includes it in theUser-Agentheader sent tomcp.stripe.com. When Cursor connects, the header readsstripe-mcp-local/0.3.1 (cursor)instead of the staticstripe-mcp-local/0.3.1.Changes
initializemessage forclientInfo.namebefore building headers.extractClientName(): Parses aJSONRPCMessageand returns the client name if the message is aninitializerequest withclientInfo.buildUserAgent(): Appends the client name in parentheses to the base user agent string.All messages are still forwarded unchanged - the proxy only peeks at the first message for metadata.
Testing
All CI checks pass locally:
pnpm run build- cleanpnpm run lint- cleanpnpm run prettier-check- cleanpnpm run test- 17/17 passing (6 new + 11 existing)Fixes #250
This contribution was developed with AI assistance (Claude Code).