-
Notifications
You must be signed in to change notification settings - Fork 5
Add environment variable support for stdio MCP servers #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: garland3 <1162675+garland3@users.noreply.github.com>
Co-authored-by: garland3 <1162675+garland3@users.noreply.github.com>
🔒 Security Scan ResultsSecurity Scan SummaryScan ResultsPython SAST (Bandit)Recommendations
|
1 similar comment
🔒 Security Scan ResultsSecurity Scan SummaryScan ResultsPython SAST (Bandit)Recommendations
|
|
@copilot please add a new mcp server in the backend folder (backend/mcp) which demostrates this capability. |
Co-authored-by: garland3 <1162675+garland3@users.noreply.github.com>
Added env-demo MCP server in
Configured in both Commit: 157de27 |
- Introduced a new configuration file in `config/overrides/env-var-mcp.json` for demonstrating environment variable passing in MCP servers.
- The `env-demo` setup includes command execution, environment variables like CLOUD_PROFILE and API_KEY (with variable substitution), and metadata such as groups, descriptions, and compliance level.
- This change provides a practical example for users to understand how to configure MCP servers using both literal values and `${VAR}` substitutions.
🔒 Security Scan ResultsSecurity Scan SummaryScan ResultsPython SAST (Bandit)Recommendations
|
Remove `import os` from test_client_env.py and `from unittest.mock import patch` from test_env_demo_server.py, as they were not utilized in the files, to clean up the codebase and reduce linting warnings.
Remove the test_mcp_json_configuration function that verified env-demo server setup in overrides/mcp.json, as this configuration check is no longer needed in the current test suite structure.
🔒 Security Scan ResultsSecurity Scan SummaryScan ResultsPython SAST (Bandit)Recommendations
|
Enables passing environment variables to stdio MCP servers via
mcp.jsonconfiguration. Supports literal values and${VAR}substitution from system environment.Changes
env: Optional[Dict[str, str]]field toMCPServerConfigenvfrom config, resolve${VAR}patterns, pass toStdioTransportenv-demoMCP server inbackend/mcp/env-demo/that demonstrates the environment variable capability with three tools:get_env_var,list_configured_env_vars, anddemonstrate_env_usageUsage
{ "my-external-tool": { "command": ["wrapper-cli", "my.external.tool@latest"], "cwd": "backend", "env": { "CLOUD_PROFILE": "my-profile-9", "CLOUD_REGION": "us-east-7", "API_KEY": "${MY_API_KEY}" } } }The
envfield only applies to stdio servers; HTTP/SSE servers ignore it. Missing env vars during substitution cause initialization failure with clear error logging.Demo Server
The
env-demoserver is configured in bothconfig/defaults/mcp.jsonandconfig/overrides/mcp.jsonand includes:Example configuration with both literal values and
${VAR}substitutionThree tools demonstrating environment variable access and usage patterns
Complete documentation in
backend/mcp/env-demo/README.mdFixes allow setting env values for individual mcps #81
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.