Skip to content

fix(cli): restrict stdio MCP environment inheritance - #13059

Open
d3f4w2 wants to merge 1 commit into
continuedev:mainfrom
d3f4w2:fix/13010-mcp-env-leak
Open

fix(cli): restrict stdio MCP environment inheritance#13059
d3f4w2 wants to merge 1 commit into
continuedev:mainfrom
d3f4w2:fix/13010-mcp-env-leak

Conversation

@d3f4w2

@d3f4w2 d3f4w2 commented Jul 29, 2026

Copy link
Copy Markdown

Description

Stdio MCP servers currently receive every variable from process.env, including unrelated cloud credentials, database secrets, and API tokens. This change stops copying the ambient environment into each server configuration and lets the MCP SDK apply its platform-safe default environment, while preserving variables explicitly configured for that server.

This also avoids mutating serverConfig.env while constructing the transport.

Fixes #13010.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

This contribution was prepared with AI assistance under the contributor's authorization and review.

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screen recording or screenshot

Not applicable; this changes the stdio MCP subprocess environment and has no UI surface.

Tests

  • Added a regression test that places a sentinel secret in process.env, initializes an stdio MCP server with one explicit variable, and verifies only the explicit variable is passed to StdioClientTransport.
  • npm test -- --run src/services/MCPService.test.ts — 21 passed
  • targeted Prettier and ESLint checks passed
  • CLI bundle build passed
  • git diff --check passed

The standalone CLI tsc --noEmit command still reports existing NodeNext import-extension errors in core/ files outside this diff; the production esbuild bundle completes successfully.

@d3f4w2
d3f4w2 marked this pull request as ready for review July 29, 2026 16:31
@d3f4w2
d3f4w2 requested a review from a team as a code owner July 29, 2026 16:31
@d3f4w2
d3f4w2 requested review from sestinj and removed request for a team July 29, 2026 16:31
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.

🔒 Security: MCP Integration Leaks Complete process.env to MCP Servers

1 participant