Fix MCP env vars: send envValueMode direct across all SDKs#484
Fix MCP env vars: send envValueMode direct across all SDKs#484SteveSandersonMS merged 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes an issue where literal environment variable values configured for MCP servers were being silently dropped. The fix ensures that all four SDKs (Node.js, Python, Go, and .NET) send envValueMode: "direct" unconditionally in session create and resume requests, which instructs the Copilot CLI runtime to treat env values as literal strings rather than as environment variable names to look up.
Changes:
- Added
envValueMode: "direct"to session create and resume requests across all four SDKs - Created test infrastructure including a minimal MCP server that echoes environment variables
- Added E2E tests across all SDKs to verify literal env values are correctly passed to MCP server subprocesses
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
test/harness/test-mcp-server.mjs |
New minimal MCP server that exposes a get_env tool for reading environment variables in tests |
test/harness/package.json |
Added @modelcontextprotocol/sdk dependency for the test MCP server |
test/harness/package-lock.json |
Package lock updates for new MCP SDK dependency and transitive dependencies |
test/snapshots/mcp_and_agents/should_pass_literal_env_values_to_mcp_server_subprocess.yaml |
Replay snapshot for the new E2E test |
nodejs/src/client.ts |
Added envValueMode: "direct" to both create and resume session requests |
nodejs/test/e2e/mcp_and_agents.test.ts |
Added E2E test for literal env values and updated test harness to support COPILOT_CLI_PATH |
nodejs/test/e2e/harness/sdkTestContext.ts |
Added support for COPILOT_CLI_PATH environment variable |
python/copilot/client.py |
Added envValueMode: "direct" to both create and resume session payloads |
python/e2e/testharness/context.py |
Added support for COPILOT_CLI_PATH environment variable |
python/e2e/test_mcp_and_agents.py |
Added E2E test for literal env values with test server path resolution |
go/types.go |
Added EnvValueMode field to createSessionRequest and resumeSessionRequest structs |
go/client.go |
Set EnvValueMode: "direct" on create and resume requests |
go/internal/e2e/mcp_and_agents_test.go |
Added E2E test for literal env values |
dotnet/src/Client.cs |
Added "direct" parameter to session create/resume calls and updated record signatures |
dotnet/test/Harness/E2ETestContext.cs |
Set CliPath using COPILOT_CLI_PATH if available for E2E tests |
dotnet/test/McpAndAgentsTests.cs |
Added E2E test for literal env values with helper method to find test harness directory |
Files not reviewed (1)
- test/harness/package-lock.json: Language not supported
✅ Cross-SDK Consistency Review: APPROVEDI've reviewed PR #484 for consistency across all four SDK implementations (Node.js, Python, Go, and .NET). Excellent work on maintaining feature parity! Consistency Verified ✓All four SDKs implement the MCP environment variable fix identically:
No Consistency Issues FoundThis PR exemplifies excellent multi-SDK development practices. The changes maintain feature parity while respecting each language's conventions (camelCase, snake_case, PascalCase).
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
866d7db to
cbb5e33
Compare
✅ SDK Consistency Review: ExcellentThis PR demonstrates exemplary cross-SDK consistency. The Consistency VerificationAll SDKs Updated ✅
Feature Parity ✅
Test Coverage ✅
API Naming Consistency ✅
SummaryNo consistency issues found. This PR fixes the MCP environment variable handling bug across all SDK implementations with complete feature parity and comprehensive test coverage. Great work! 🎉
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bcfc363 to
805ce4d
Compare
The CLI now injects dynamic <reminder> tags with SQL table state into user messages. These tags vary based on runtime state and should not affect snapshot matching. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Cross-SDK Consistency ReviewI've reviewed this PR for consistency across all four SDK implementations (Node.js, Python, Go, and .NET). No consistency issues found — this is an exemplary cross-language fix! What Was ChangedThis PR adds Consistency Analysis✅ Feature Parity: EXCELLENT
✅ API Naming: CONSISTENT
✅ Implementation: UNIFORM
✅ Testing: COMPREHENSIVE
SummaryThis PR demonstrates excellent cross-SDK development practices with perfect feature parity and consistent implementation across all language targets. 🎯
|
|
You've. Been a slut this whole time you can change this shit all you want i
got thr original
…On Tue, Feb 17, 2026, 11:40 AM github-actions[bot] ***@***.***> wrote:
*github-actions[bot]* left a comment (github/copilot-sdk#484)
<#484 (comment)>
✅ Cross-SDK Consistency Review
I've reviewed this PR for consistency across all four SDK implementations
(Node.js, Python, Go, and .NET). *No consistency issues found* — this is
an exemplary cross-language fix!
What Was Changed
This PR adds envValueMode: "direct" to session create and resume requests
in all four SDKs to fix MCP environment variable handling (issues #163
<#163> and #444
<#444>).
Consistency Analysis
*✅ Feature Parity: EXCELLENT*
- All four SDKs implement the identical fix
- Both CreateSession and ResumeSession operations updated in each
language
- Consistent E2E test coverage across all implementations
*✅ API Naming: CONSISTENT*
- JSON field name: envValueMode (camelCase) — uniform across all
languages
- Language-specific naming follows proper conventions:
- TypeScript: envValueMode ✅
- Python: payload["envValueMode"] ✅
- Go: EnvValueMode (struct field) ✅
- .NET: EnvValueMode (record parameter) ✅
*✅ Implementation: UNIFORM*
- All SDKs unconditionally send "direct" as the value
- No user configuration exposed (appropriate for this bug fix)
- Applied to both create and resume operations consistently
*✅ Testing: COMPREHENSIVE*
- All four SDKs include the same E2E test scenario
- Test verifies literal env values (TEST_SECRET: "hunter2") are passed
to MCP server subprocess
- Shared snapshot:
test/snapshots/mcp_and_agents/should_pass_literal_env_values_to_mcp_server_subprocess.yaml
Summary
This PR demonstrates excellent cross-SDK development practices with
perfect feature parity and consistent implementation across all language
targets. 🎯
AI generated by SDK Consistency Review Agent
<https://github.com/github/copilot-sdk/actions/runs/22106830722>
—
Reply to this email directly, view it on GitHub
<#484 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/B4HEF3LMMIM37EK3UAJ5NTT4MNAA7AVCNFSM6AAAAACVJJB5V6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTSMJVG44DKOJVG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Fixes #163
Fixes #444
Problem
When SDK users configure MCP servers with literal environment variable values (e.g.,
env: { TEST_SECRET: "hunter2" }), the values are silently dropped. This is because the runtime's defaultindirectmode treats env values as names of environment variables to look up fromprocess.env, not as literal values.Solution
All four SDKs now send
envValueMode: "direct"in session create and resume requests, telling the runtime to treat env values as literal strings.Depends on runtime PR: https://github.com/github/copilot-agent-runtime/pull/3307
THIS PR WILL FAIL IN CI UNTIL WE GET THE RUNTIME THAT INCLUDES THE FIX