[BUG] `/doctor` reports missing env vars without checking settings.json `env` field
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?
/doctor (and claude doctor) has two issues with MCP server environment variable validation:
1. Doesn't check settings.json env field
/doctor reports that a plugin MCP server is invalid due to missing environment variables, even when those variables are defined in the env field of ~/.claude/settings.json. The MCP server works correctly — the env var is picked up at runtime — but the doctor validation check doesn't account for it.
Example output:
plugin:github [github]: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN
Actual configuration in ~/.claude/settings.json:
{
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
}
}
The GitHub plugin MCP server connects and works fine (verified via get_me tool call), confirming the env var is properly inherited. The doctor check is a false positive.
2. Validates disabled MCP servers
/doctor also validates MCP servers that have been explicitly disabled (e.g., via disabledMcpServers in project settings or "disabled": true on the server config). For example, it checks the greptile plugin MCP server even though it's listed in disabledMcpServers. Disabled servers shouldn't be validated since they won't be started.
What Should Happen?
/doctorshould check all sources of environment variables before reporting them as missing:
- The MCP server's own
envfield - The top-level
envfield insettings.jsonandsettings.local.json - The shell/process environment
/doctorshould skip validation entirely for MCP servers that are disabled.
Error Messages/Logs
plugin:github [github]: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN
Steps to Reproduce
For issue 1:
- Install the
githubplugin (github@claude-plugins-official) - Instead of setting
GITHUB_PERSONAL_ACCESS_TOKENin the plugin's MCP server env or the shell profile, set it in~/.claude/settings.json:
``json``
{
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_..."
}
}
- Run
claude doctoror/doctor - Observe false positive warning about missing env var
- Verify the GitHub MCP server actually works (e.g., use
get_metool)
For issue 2:
- Install a plugin that provides an MCP server (e.g.,
greptile) - Disable the MCP server via project
disabledMcpServersor"disabled": true - Run
claude doctoror/doctor - Observe that the disabled server is still validated
Claude Model
None
Is this a regression?
No
Claude Code Version
2.1.45
Platform
Anthropic API (Max subscription)
Operating System
macOS
Terminal/Shell
bash
Additional Information
The env field in settings.json is a supported configuration for setting process-wide environment variables. The doctor validation should be aware of all env var sources and should respect disabled state to avoid confusing false positives.
---
🤖 Generated with Claude Code
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗