Skip to content

Proxy MCP client name in local stdio server User-Agent#304

Open
mvanhorn wants to merge 1 commit intostripe:mainfrom
mvanhorn:osc/250-proxy-mcp-client-name-user-agent
Open

Proxy MCP client name in local stdio server User-Agent#304
mvanhorn wants to merge 1 commit intostripe:mainfrom
mvanhorn:osc/250-proxy-mcp-client-name-user-agent

Conversation

@mvanhorn
Copy link

Summary

Extracts the MCP client name from the initialize request and includes it in the User-Agent header sent to mcp.stripe.com. When Cursor connects, the header reads stripe-mcp-local/0.3.1 (cursor) instead of the static stripe-mcp-local/0.3.1.

Changes

  • Deferred HTTP transport creation: The HTTP transport is now created on the first stdio message instead of upfront. This lets us inspect the initialize message for clientInfo.name before building headers.
  • extractClientName(): Parses a JSONRPCMessage and returns the client name if the message is an initialize request with clientInfo.
  • buildUserAgent(): Appends the client name in parentheses to the base user agent string.
  • Tests: 6 new test cases covering client name extraction (Cursor, Claude Desktop, missing clientInfo, non-initialize messages, responses, notifications) and User-Agent formatting.

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 - clean
  • pnpm run lint - clean
  • pnpm run prettier-check - clean
  • pnpm run test - 17/17 passing (6 new + 11 existing)

Fixes #250

This contribution was developed with AI assistance (Claude Code).

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
@cla-assistant
Copy link

cla-assistant bot commented Mar 15, 2026

CLA assistant check
All committers have signed the CLA.

@cla-assistant
Copy link

cla-assistant bot commented Mar 15, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proxy mcp client name in the local mcp stdio server

1 participant