[DOCS] MCP stdio servers documentation does not mention they receive CLAUDE_PROJECT_DIR environment variable

Resolved 💬 2 comments Opened May 11, 2026 by coygeek Closed May 12, 2026

Documentation Type

Incorrect/outdated documentation

Documentation Location

https://code.claude.com/docs/en/plugins-reference

Section/Topic

Environment variables exported to MCP or LSP server subprocesses

Current Documentation

The plugins-reference.md documents environment variables for MCP/LSP server subprocesses but omits CLAUDE_PROJECT_DIR:

Claude Code provides two variables for referencing plugin paths. Both are substituted inline anywhere they appear in skill content, agent content, hook commands, monitor commands, and MCP or LSP server configs. Both are also exported as environment variables to hook processes and MCP or LSP server subprocesses. ${CLAUDE_PLUGIN_ROOT}: the absolute path to your plugin's installation directory... ${CLAUDE_PLUGIN_DATA}: a persistent directory for plugin state that survives updates...

The MCP stdio server documentation does not mention that CLAUDE_PROJECT_DIR is available to stdio servers:

User environment access: Access to same environment variables as manually configured servers

The env-vars.md file does not document CLAUDE_PROJECT_DIR as an environment variable available to MCP stdio servers.

What's Wrong or Missing?

As of v2.1.139, MCP stdio servers now receive CLAUDE_PROJECT_DIR in their environment, matching hooks. However:

  1. The plugins-reference.md section on "Environment variables" only lists ${CLAUDE_PLUGIN_ROOT} and ${CLAUDE_PLUGIN_DATA} as variables exported to MCP/LSP server subprocesses. It does not mention CLAUDE_PROJECT_DIR.
  1. The MCP documentation does not document this new environment variable availability for stdio servers.
  1. The env-vars.md file does not document CLAUDE_PROJECT_DIR in the context of MCP stdio servers.

This creates a documentation gap: users who configure MCP stdio servers (especially plugin-provided ones) may not know they can rely on CLAUDE_PROJECT_DIR in their server configurations and scripts.

Suggested Improvement

Update plugins-reference.md "Environment variables" section to include CLAUDE_PROJECT_DIR:

Claude Code provides three variables for referencing paths. All three are substituted inline anywhere they appear in skill content, agent content, hook commands, monitor commands, and MCP or LSP server configs. All three are also exported as environment variables to hook processes and MCP or LSP server subprocesses. - ${CLAUDE_PROJECT_DIR}: the project root directory - ${CLAUDE_PLUGIN_ROOT}: the plugin's installation directory - ${CLAUDE_PLUGIN_DATA}: the plugin's persistent data directory

Update MCP.md "Plugin-provided MCP servers" section to explicitly mention CLAUDE_PROJECT_DIR:

User environment access: Access to same environment variables as manually configured servers, including CLAUDE_PROJECT_DIR (the project root)

Consider adding CLAUDE_PROJECT_DIR to env-vars.md as a documented variable available to subprocesses including MCP stdio servers.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

| Page | Line(s) | Context |
|------|---------|---------|
| https://code.claude.com/docs/en/settings | 417 | File suggestion command docs confirm it "runs with the same environment variables as hooks, including CLAUDE_PROJECT_DIR" |
| https://code.claude.com/docs/en/plugins-reference | 538-540 | Lists ${CLAUDE_PLUGIN_ROOT} and ${CLAUDE_PLUGIN_DATA} but omits CLAUDE_PROJECT_DIR |
| https://code.claude.com/docs/en/mcp | 408 | Plugin MCP servers section says "Access to same environment variables as manually configured servers" but doesn't specify CLAUDE_PROJECT_DIR |
| https://code.claude.com/docs/en/hooks | 406 | Documents $CLAUDE_PROJECT_DIR for hooks |

Total scope: 4 pages affected

Changelog entry (v2.1.139):

MCP stdio servers now receive CLAUDE_PROJECT_DIR in their environment, matching hooks. Plugin configs can reference ${CLAUDE_PROJECT_DIR} in commands.

View original on GitHub ↗

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