Skip to content

feat: Overwriting User-Agent on CLI requests for MCP mode#21

Merged
sbosio merged 2 commits intomainfrom
sbosio/overwrite-user-agent
Apr 10, 2025
Merged

feat: Overwriting User-Agent on CLI requests for MCP mode#21
sbosio merged 2 commits intomainfrom
sbosio/overwrite-user-agent

Conversation

@sbosio
Copy link
Copy Markdown
Contributor

@sbosio sbosio commented Apr 9, 2025

Description

Here we include changes to:

  • Overwrite the User-Agent value sent with Heroku CLI requests when running in MCP mode by means of setting the HEROKU_HEADERS env var with the required value on the spawned CLI process.
  • Additionally we set the env var HEROKU_MCP_SERVER_VERSION that will be used by the CLI to know the MCP server version and add it to the information sent to Backboard and Honeycomb to enable us to create metrics based on MCP server usage (see PR #3279).

Testing

  • Checkout this branch and run npm install && npm run build
  • Start the MCP inspector with npx @modelcontextprotocol/inspector dist/index.js
  • Open the inspector web interface (usually at http://localhost:5173, but look for the message 🔍 MCP Inspector is up and running at ... as it might be up at a different port).
  • On the inspector click the Add Environment Variable and add the variable DEBUG with value http,http:headers.
  • Click Connect and then List Tools. Select one of the tools like list_apps and click Run Tool.
  • On the Tool Results, check that requests to Platform API use the MCP version user agent string instead of the CLI version. This doesn't effect Backboard requests, though, because it doesn't honor the HEROKU_HEADERS env var like @heroku/cli-command, but that's not a problem because we will be sending the version on the payload.

SOC2 Compliance

GUS Work Item: W-18205123

@sbosio sbosio marked this pull request as ready for review April 10, 2025 16:28
@sbosio sbosio requested a review from a team as a code owner April 10, 2025 16:28
@sbosio sbosio merged commit 4551460 into main Apr 10, 2025
1 check passed
@sbosio sbosio deleted the sbosio/overwrite-user-agent branch April 10, 2025 17:57
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.

2 participants