Skip to content

fix(bot): MCP bot calls run with the server's environment - #708

Merged
leemour merged 1 commit into
mainfrom
fix/bot-mcp-env
Oct 17, 2026
Merged

leemour merged 1 commit into
mainfrom
fix/bot-mcp-env

Conversation

@leemour

@leemour leemour commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

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

  • `botMcpRun` spreads the server's environment into `run`, as tg's hook does.
  • Test: the bot MCP server with `MAX_READ_ONLY=1` refuses `messages send` and sends nothing to the Bot API (failed before the fix: the send went through).
  • CHANGELOG entry under «Не выпущено → Исправлено».

Testing

typecheck, lint, docs:check, parity:check, `pnpm test:matrix` (full vitest + matrix: 911 tested, 0 missing).

🤖 Generated with Claude Code

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>
@leemour
leemour merged commit be0f2dd into main Oct 17, 2026
2 checks passed
@leemour
leemour deleted the fix/bot-mcp-env branch October 17, 2026 11:09
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.

1 participant