Skip to content

Document how to use shell environment variables in MCP server configuration #7521

Open

Description

@PaulRBerg

What is the type of issue?

Documentation is missing

What is the issue?

There is no documentation explaining how to reference shell environment variables when configuring MCP servers in config.toml. Users need to pass API keys and other secrets to MCP servers, but it's unclear which syntax works:

Option 1 - Simple variable reference:

[mcp_servers.context7]
  args = ["-y", "@upstash/context7-mcp", "--api-key", "$API_KEY_CONTEXT7_MCP"]
  command = "npx"

Option 2 - Brace-wrapped variable reference:

[mcp_servers.context7]
  args = ["-y", "@upstash/context7-mcp", "--api-key", "${API_KEY_CONTEXT7_MCP}"]
  command = "npx"

The documentation should clarify:

  1. Which syntax is supported (or if both work)
  2. Whether variable expansion happens at config load time or command execution time
  3. Any gotchas with quoting or escaping

Important

Users should also be aware that they may need to set shell_environment_policy.ignore_default_excludes to true for environment variables to be passed through correctly. See #3064 for related discussion.

Where did you find it?

Activity

  1. added
    documentation
    CLI
    mcp
    on Dec 3, 2025
  2. github-actions commented on Dec 3, 2025

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. PaulRBerg commented on Dec 3, 2025

    @PaulRBerg
    Author

    Issue #7367 is related but not quite the same. I am asking to document how to load env vars.

  4. jpcaparas commented on Dec 30, 2025

    @jpcaparas

    This is the correct way to pass environment variables to MCP servers

    #3064 (comment)

  5. added a commit that references this issue on Feb 18, 2026
    a7af082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIdocumentationmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions