Repository navigation
fix(bot): MCP bot calls run with the server's environment - #708
Merged
Merged
Conversation
botMcpRun handed the command it runs the streams, tty and answer from the shared bot MCP server, but dropped env. A tool call therefore ran under process.env instead of the server's environment, so overrides such as MAX_READ_ONLY or a config directory did not apply. Pass the whole environment through, as tg does. The new test starts the bot MCP server with MAX_READ_ONLY=1 and checks that messages send is refused with no request to the Bot API. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Task
`max bot mcp` tool calls ignored the server's environment.
Why
`botMcpRun` (src/commands/bot-messenger.ts) passed streams, tty and answer to the command it runs, but dropped `env`. Each tool call ran under `process.env`, so `MAX_READ_ONLY`, profile and config-directory overrides set for the server did not apply. tg already passes the whole environment through.
What
Testing
typecheck, lint, docs:check, parity:check, `pnpm test:matrix` (full vitest + matrix: 911 tested, 0 missing).
🤖 Generated with Claude Code