I'm registering a local stdio MCP server for Claude Code (CLI) programmatically by writing config files (not via `claude mcp add`). Constraints: CLAUDE_CONFIG_DIR is set to a per-"pool" directory; I want the MCP server available to ALL projects that run with that CLAUDE_CONFIG_DIR, and I want its single tool pre-approved so no permission prompt appears. The server is launched as `/abs/path/to/app --mcp-panel` (a stdio JSON-RPC server), server name `aicontrol`, tool name `write_panel`.

Answer precisely, with exact file paths, JSON keys, and current syntax:

1. To register a stdio MCP server at USER/GLOBAL scope by writing a file (so it applies to every project), what exact file and JSON structure do I write? Is it `$CLAUDE_CONFIG_DIR/settings.json` with an `mcpServers` key, or a separate file (e.g. `~/.claude.json`, or `.mcp.json`)? Does Claude Code read `mcpServers` from settings.json, or only from `.mcp.json` / the `claude mcp add` store? Give the exact JSON snippet for a stdio server with `command` and `args`.

2. If the server is defined in a project `.mcp.json`, does it require `enabledMcpjsonServers` (or an approval) in settings to be trusted/auto-enabled without an interactive "trust this MCP server?" prompt? What's the exact key/value to auto-approve it?

3. What is the EXACT `permissions.allow` string to pre-authorize calling the tool without a prompt? Confirm the name-mangling: server `aicontrol` + tool `write_panel` → is it `mcp__aicontrol__write_panel`? Can I also allow all tools of the server with `mcp__aicontrol`?

4. Does the stdio MCP server child process inherit the environment of the `claude` process (I need an env var `AI_CONTROL_PANEL` that claude has to be visible to the server)? Any config needed to pass env through, or is it inherited by default? Can I also set `env` in the server config?

5. Anything that differs by Claude Code version worth noting.

Be concrete — I'm writing these files from Rust, so I need the exact schema.


I'll fetch the Claude Code documentation to get the exact current schema for MCP server registration and permissions.


WebFetch

Prompt: MCP server configuration, stdio server, .mcp.json, settings.json, registration


Prompt: stdio MCP server registration JSON structure settings.json .mcp.json