[BUG] MCP stdio server env vars not propagated to subprocess — server fails to connect

Resolved 💬 2 comments Opened Apr 6, 2026 by garfieldthesam Closed Apr 6, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Bug: MCP stdio server env config not propagated to subprocess

Summary

MCP servers configured with env in .claude.json project-level config do not receive the environment variables when launched by Claude Code. The server starts but fails to connect because required env vars are missing.

Environment

  • Claude Code version: 2.1.92 (latest)
  • OS: macOS (Darwin 25.4.0)
  • Shell: zsh
  • MCP server: dbt-mcp (tested with v1.9.3 and v1.12.0)

Reproduction

1. Add an MCP server with env config

claude mcp add dbt-cloud -s local \
  -e DBT_HOST=<my_host>.us1.dbt.com \
  -e DBT_CLOUD_API_TOKEN=<token> \
  -e DBT_CLOUD_ACCOUNT_ID=<acct_id> \
  -- uvx --from 'dbt-mcp==1.12.0' dbt-mcp serve

This produces the following entry in .claude.json:

{
  "projects": {
    "/path/to/project": {
      "mcpServers": {
        "dbt-cloud": {
          "type": "stdio",
          "command": "uvx",
          "args": ["--from", "dbt-mcp==1.12.0", "dbt-mcp", "serve"],
          "env": {
            "DBT_HOST": "<my_host>.us1.dbt.com",
            "DBT_CLOUD_API_TOKEN": "<token>",
            "DBT_CLOUD_ACCOUNT_ID": "<acct_id>"
          }
        }
      }
    }
  }
}

2. Check server status

claude mcp get dbt-cloud
# Status: ✗ Failed to connect

3. Run the same command manually with env vars — it works

DBT_HOST=<my_host>.us1.dbt.com \
DBT_CLOUD_API_TOKEN=<token> \
DBT_CLOUD_ACCOUNT_ID=<acct_id> \
uvx --from 'dbt-mcp==1.12.0' dbt-mcp serve 2>&1

Output (server starts successfully):

INFO [dbt_mcp.mcp.server] Multi-project mode disabled -> Env-var mode
INFO [dbt_mcp.mcp.server] Registering product docs tools
INFO [dbt_mcp.mcp.server] Registering MCP server tools
INFO [dbt_mcp.mcp.server] Registering semantic layer tools
INFO [dbt_mcp.mcp.server] Registering discovery tools
INFO [dbt_mcp.mcp.server] Registering dbt admin API tools
INFO [dbt_mcp.mcp.server] Starting MCP server
INFO [dbt_mcp.mcp.server] Registering proxied tools

4. Without env vars, it fails to register platform tools

uvx --from 'dbt-mcp==1.12.0' dbt-mcp serve 2>&1
WARNING [dbt_mcp.config.settings] Platform features have been automatically disabled due to missing DBT_HOST.
INFO [dbt_mcp.mcp.server] Registering product docs tools
INFO [dbt_mcp.mcp.server] Registering MCP server tools
INFO [dbt_mcp.mcp.server] Starting MCP server
INFO [dbt_mcp.mcp.server] Shutting down MCP server

The server shuts down immediately because it has no useful tools to serve (no platform features).

Key observations

  • Other MCP servers in the same project config work fine. The databricks and dbt-core servers use the same env pattern in the same .claude.json file and connect successfully.
  • The only structural difference: the working servers were added without an explicit "type": "stdio" field, while claude mcp add for dbt-cloud added "type": "stdio". Removing the type field manually did not resolve the issue.
  • Removing and re-adding the server (claude mcp remove + claude mcp add) does not fix it.
  • Upgrading the dbt-mcp package version does not fix it.

What Should Happen?

Expected behavior

Environment variables specified in the env config of an MCP server entry should be passed to the subprocess when Claude Code launches it.

Actual behavior

The subprocess is launched without the configured environment variables, causing the MCP server to fail to initialize its platform features and shut down.

Error Messages/Logs

Steps to Reproduce

1. Add dbt-mcp as an MCP server with required env vars

claude mcp add dbt-cloud -s local \
  -e DBT_HOST=<my_host>.us1.dbt.com \
  -e DBT_CLOUD_API_TOKEN=<your_token> \
  -e DBT_CLOUD_ACCOUNT_ID=<acct_id> \
  -- uvx --from 'dbt-mcp==1.12.0' dbt-mcp serve

2. Observe the failure

claude mcp get dbt-cloud
# Status: ✗ Failed to connect

3. Verify the env vars are in the config file

cat ~/.claude.json | python3 -c "
import json, sys
d = json.load(sys.stdin)
for proj, cfg in d.get('projects', {}).items():
    srv = cfg.get('mcpServers', {}).get('dbt-cloud')
    if srv:
        print(json.dumps(srv, indent=2))
"

Expected output (env vars are present in config):

{
  "type": "stdio",
  "command": "uvx",
  "args": ["--from", "dbt-mcp==1.12.0", "dbt-mcp", "serve"],
  "env": {
    "DBT_HOST": "<my_host>.us1.dbt.com",
    "DBT_CLOUD_API_TOKEN": "<your_token>",
    "DBT_CLOUD_ACCOUNT_ID": "<acct_id>"
  }
}

4. Run the same command manually — it works

DBT_HOST=<my_host>.us1.dbt.com \
DBT_CLOUD_API_TOKEN=<your_token> \
DBT_CLOUD_ACCOUNT_ID=<acct_id> \
uvx --from 'dbt-mcp==1.12.0' dbt-mcp serve 2>&1

Output (server starts successfully):

INFO [dbt_mcp.mcp.server] Registering product docs tools
INFO [dbt_mcp.mcp.server] Registering semantic layer tools
INFO [dbt_mcp.mcp.server] Registering discovery tools
INFO [dbt_mcp.mcp.server] Registering dbt admin API tools
INFO [dbt_mcp.mcp.server] Starting MCP server

5. Without env vars, the server shuts down immediately

uvx --from 'dbt-mcp==1.12.0' dbt-mcp serve 2>&1
WARNING [dbt_mcp.config.settings] Platform features have been automatically disabled due to missing DBT_HOST.
INFO [dbt_mcp.mcp.server] Starting MCP server
INFO [dbt_mcp.mcp.server] Shutting down MCP server

This is the behavior Claude Code triggers — the server never receives DBT_HOST, so it disables all platform features and exits.

6. Confirmed working in MCP Inspector

Using MCP Inspector with the same command and env vars added via the UI, the server connects and registers all tools successfully. This rules out a server-side issue.

Additional context

  • Other MCP servers in the same .claude.json project config (e.g., databricks, dbt-core) use the same env pattern and connect successfully.
  • Removing and re-adding the server does not fix it.
  • Claude Code version: 2.1.92 (latest as of 2025-04-06).
  • macOS Darwin 25.4.0, zsh.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.92

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗