Support for expansion in mcp servers #1962

Closed
opened 2026-02-16 17:33:27 -05:00 by yindo · 6 comments
Owner

Originally created by @jakeleventhal on GitHub (Oct 5, 2025).

https://docs.claude.com/en/docs/claude-code/mcp#environment-variable-expansion-in-mcp-json
This feature should be supported in opencode to allow committing this to source. Better yet, just evaluating a claude .mcp.json file would be great so the config doesn't need to be recreated for claude, opencode, etc.

Originally created by @jakeleventhal on GitHub (Oct 5, 2025). https://docs.claude.com/en/docs/claude-code/mcp#environment-variable-expansion-in-mcp-json This feature should be supported in opencode to allow committing this to source. Better yet, just evaluating a claude .mcp.json file would be great so the config doesn't need to be recreated for claude, opencode, etc.
yindo closed this issue 2026-02-16 17:33:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 5, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #318: Requests ability to pass credentials using environment variables and command execution in config files, including for MCP servers with similar syntax
  • #231: Requests environment variable evaluation and external command execution in config files

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 5, 2025): This issue might be a duplicate of existing issues. Please check: - #318: Requests ability to pass credentials using environment variables and command execution in config files, including for MCP servers with similar syntax - #231: Requests environment variable evaluation and external command execution in config files Feel free to ignore if none of these address your specific case.
Author
Owner

@jakeleventhal commented on GitHub (Oct 5, 2025):

Duplicate of https://github.com/sst/opencode/issues/231 and https://github.com/sst/opencode/issues/318

@jakeleventhal commented on GitHub (Oct 5, 2025): Duplicate of https://github.com/sst/opencode/issues/231 and https://github.com/sst/opencode/issues/318
Author
Owner

@berenar commented on GitHub (Oct 20, 2025):

Sorry, this was closed as completed, but I couldn't figure out how does this work, can someone reference the docs or provide instructions?
This doesn't seem to work
And here it says that {env:SECRET} should work, but it doesn't work for me.

  "mcp": {
    "context7": {
      "type": "remote",
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
      }
  }

Update: this seems to work

"mcp": {
    "context7": {
      "type": "local",
      "command": [
        "npx",
        "-y",
        "@upstash/context7-mcp",
        "--api-key",
        "{env:CONTEXT7_API_KEY}"
      ],
      "enabled": true
    }
}
@berenar commented on GitHub (Oct 20, 2025): Sorry, this was closed as completed, but I couldn't figure out how does this work, can someone reference the docs or provide instructions? [This](https://opencode.ai/docs/config/#env-vars) doesn't seem to work And [here](https://opencode.ai/docs/mcp-servers/#context7) it says that `{env:SECRET}` should work, but it doesn't work for me. ``` "mcp": { "context7": { "type": "remote", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}" } } ``` Update: this seems to work ``` "mcp": { "context7": { "type": "local", "command": [ "npx", "-y", "@upstash/context7-mcp", "--api-key", "{env:CONTEXT7_API_KEY}" ], "enabled": true } } ```
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

@berenar this is my config:

    "context7": {
      "type": "remote",
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}",
      },
    },

It works:

Image

I did hear some people having trouble with context7 today, possibly due to us-east-1 outage?

@rekram1-node commented on GitHub (Oct 20, 2025): @berenar this is my config: ``` "context7": { "type": "remote", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}", }, }, ``` It works: <img width="1677" height="594" alt="Image" src="https://github.com/user-attachments/assets/763b0a50-5af0-4691-961a-1ebb3c03863f" /> I did hear some people having trouble with context7 today, possibly due to us-east-1 outage?
Author
Owner

@berenar commented on GitHub (Oct 20, 2025):

@rekram1-node that must have been it 😅 It works now, thanks!

@berenar commented on GitHub (Oct 20, 2025): @rekram1-node that must have been it 😅 It works now, thanks!
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

np

@rekram1-node commented on GitHub (Oct 20, 2025): np
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1962