Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
OpenCode's MCP server configuration accepts env values as literal strings.
This makes it incompatible with secret managers that expose secrets as files on disk rather than as host environment variables — such as sops-nix, systemd credentials, Docker secrets, or pass.
With file-based secret managers, secrets are decrypted at runtime and written to paths like /run/secrets/my_token. They are never present as environment variables in the OpenCode process itself, so there is currently no way to inject them into MCP server environments.
Proposed Solution
Introduce an env_files key in the MCP server config that maps environment variable names to file paths. OpenCode would read the file contents and set the variable before spawning the MCP server process — no shell involved:
"codeberg": {
"type": "local",
"command": "/path/to/forgejo-mcp",
"args": ["transport", "stdio", "--url", "https://codeberg.org"],
"env_files": {
"FORGEJO_ACCESS_TOKEN": "/run/secrets/codeberg_token"
}
}
Why not use host environment variables?
File-based secret managers like sops-nix or systemd credentials do not populate the host environment. The secrets only exist as files at runtime and are not accessible via process.env in the OpenCode process.
Related
A similar request exists for charmbracelet/crush:
charmbracelet/crush#2334
Alternatives Considered
- Wrapper shell scripts per MCP server — functional but requires boilerplate outside the config and complicates NixOS/Home Manager module integration
- Storing secrets as host env vars — not applicable for file-based managers
Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
OpenCode's MCP server configuration accepts
envvalues as literal strings.This makes it incompatible with secret managers that expose secrets as files on disk rather than as host environment variables — such as sops-nix, systemd credentials, Docker secrets, or pass.
With file-based secret managers, secrets are decrypted at runtime and written to paths like
/run/secrets/my_token. They are never present as environment variables in the OpenCode process itself, so there is currently no way to inject them into MCP server environments.Proposed Solution
Introduce an
env_fileskey in the MCP server config that maps environment variable names to file paths. OpenCode would read the file contents and set the variable before spawning the MCP server process — no shell involved:Why not use host environment variables?
File-based secret managers like sops-nix or systemd credentials do not populate the host environment. The secrets only exist as files at runtime and are not accessible via
process.envin the OpenCode process.Related
A similar request exists for charmbracelet/crush:
charmbracelet/crush#2334
Alternatives Considered