Skip to content

[BUG] Claude .mcp.json drops env for self-defined stdio MCP servers #1222

@imk1t

Description

@imk1t

Describe the bug

When a self-defined stdio MCP server declares env in apm.yml, APM generates Claude Code .mcp.json with an empty env: {} object.

The environment variables are present in the apm.yml MCP declaration, but they are not preserved in the Claude runtime config.

To Reproduce

Steps to reproduce the behavior:

  1. Create a project with this apm.yml:
name: apm-claude-env-repro
version: 1.0.0
target:
  - claude
dependencies:
  apm: []
  mcp:
    - name: env-demo
      registry: false
      transport: stdio
      command: npx
      args:
        - -y
        - example-mcp
      env:
        DEMO_ENV: demo-value
includes: auto
scripts: {}
  1. Ensure Claude project config directory exists:
mkdir -p .claude
  1. Run:
apm install --target claude --no-policy
  1. Inspect the generated file:
cat .mcp.json
  1. Observe that env is generated as {}.

Expected behavior

The generated .mcp.json should preserve the declared stdio environment variables:

{
  "mcpServers": {
    "env-demo": {
      "type": "stdio",
      "command": "npx",
      "env": {
        "DEMO_ENV": "demo-value"
      },
      "args": [
        "-y",
        "example-mcp"
      ]
    }
  }
}

Environment (please complete the following information):

  • OS: macOS 26.4.1
  • Python Version: 3.9.6
  • APM Version: Agent Package Manager (APM) CLI version 0.12.4 (6aceef7)
  • VSCode Version (if relevant): N/A

Logs

Actual generated .mcp.json:

{
  "mcpServers": {
    "env-demo": {
      "type": "stdio",
      "command": "npx",
      "env": {},
      "args": [
        "-y",
        "example-mcp"
      ]
    }
  }
}

apm install output reports success:

Successfully configured MCP server 'env-demo' for Claude Code
[*] Installed 1 MCP server

Additional context

I searched existing MCP config / env related issues and found related adapter issues, but not this exact Claude Code stdio env drop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/needs-triageNew, awaiting maintainer review.type/bugSomething does not work as documented.

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions