anomalyco / anomalyco/opencode

[BUG] MCP server env block from opencode.jsonc not passed to child process

Open Beginner friendly
#49,983 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

The env block defined under an MCP server in opencode.jsonc is not being passed to the spawned child process. The MCP server starts without the configured environment variables and falls back to degraded/in-memory mode.

Steps to Reproduce

  1. Configure an MCP server in opencode.jsonc with env vars:
{
  "mcp": {
    "acmi": {
      "type": "local",
      "command": ["acmi-mcp"],
      "env": {
        "ACMI_BRIDGE_URL": "https://example.com/bridge",
        "ACMI_BRIDGE_TOKEN": "my-token"
      }
    }
  }
}
  1. Start opencode and use the MCP server
  2. Inspect the child process environment: ps eww -p <pid> — the configured env vars are absent

Expected Behavior

The env block values should be merged into the child process environment (as issue #31778 describes the code doing with ...mcp.environment).

Actual Behavior

The child process receives only process.env without the env block merged. The MCP server reports degraded mode because it cannot find its required configuration.

Evidence

  • Process serving the session (PID 29929): zero ACMI env vars
  • Different acmi-mcp process (PID 58422, started from a shell with exports): has all ACMI env vars, works correctly
  • opencode.jsonc confirms the env block is present and correctly formatted
  • Raw curl to the bridge URL succeeds — backend is fine, this is purely a client-side env passthrough issue

Impact

Any MCP server relying on env config for authentication or endpoint configuration will silently fail. The workaround is adding exports to ~/.zshrc, but that bypasses the per-server config entirely.

Environment

  • OpenCode: latest (installed via Homebrew)
  • OS: macOS (Apple Silicon)
  • MCP server: `@madezmedia/acmi-mcp@2.0.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the MCP local-server child-process launch path and inspect how the configured env block from opencode.jsonc is combined with process.env. Reproduce with the provided ACMI configuration, then verify that the spawned process receives both configured variables and the existing environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.