What this unit solves
~/.claude.json is Claude Code’s global state file. It stores MCP server registrations, per-project trust and tool-approval records, and a collection of onboarding and account metadata. It is not a policy file for you to hand-edit; the tool writes to it. But knowing what it stores lets you open the file and locate the root cause directly when MCP won’t load, permission dialogs keep firing, or trust state seems corrupted, rather than blindly reinstalling. This unit gives you a field-by-field tour, a verifiable MCP scope model, and a clear criterion for when hand-editing is acceptable and when it is not.Learning objectives
- Describe the broad categories of information stored in
~/.claude.jsonand identify the sections most useful for troubleshooting. - Distinguish the responsibility boundary between
claude.json(state and registration) andsettings.json(behavioral policy), and avoid mixing them up. - Explain MCP’s three scopes (local / project / user), where each is stored, and how
.mcp.jsonproject trust works. - Use the contents of
claude.jsonto locate the root cause when an MCP server fails to load or a trust dialog fires repeatedly.
1. What claude.json is: a state file, not a policy file
~/.claude.json is a user-level state file located in your home directory (on Windows: C:\Users\<your-account>\.claude.json). Claude Code itself is the primary writer; if the file does not exist at first launch it is created automatically.
It has a fundamental boundary with the settings.json discussed in 02-3:
| File | The question it answers | Who writes it | Should you hand-edit it |
|---|---|---|---|
~/.claude.json | ”What has Claude Code remembered?” (which MCPs exist, does this project have trust, which tools have been approved) | Written automatically by the tool | No (with narrow exceptions for troubleshooting; see Section 5) |
settings.json | ”How should Claude Code behave?” (allow / deny policy, hooks, env) | You | Yes |
settings.json describes “how to behave”: permission policy, hooks, env — the policy file you edit. claude.json records “what has happened”: which MCP servers were registered, which project you trusted, which tools you clicked “always allow” on. This is state maintained by the tool, not something you write.
Keeping this boundary clear avoids the most common misuse: hand-writing “I always want to allow this tool” intent into claude.json rather than into settings.json’s permissions.allow. The former is state (written by the tool); the latter is policy (written by you). Mixing them means the tool’s next state update will overwrite whatever you wrote by hand.
2. What it stores: a field tour
The most important section of~/.claude.json is projects: an object keyed by absolute project paths, with each project’s private state underneath, including the MCP servers registered at local scope for that project. The structure the official documentation provides (after you add a local server from /path/to/your/project) looks like this [1]:
projects, the file stores a batch of tool-managed metadata: whether onboarding is complete, theme preference, launch count, login account information, and similar internal state.
When troubleshooting, the sections you will actually use are projects.<your-project-path>.mcpServers (first place to look when MCP won’t connect) and the project’s trust and tool-approval state (look here when the trust dialog keeps firing).
3. Division of labor with settings.json: memory vs. policy
Two practical rules: write policy intosettings.json, not claude.json; let the tool maintain state, and do not reach around the tool to hand-edit trust records in claude.json.
4. MCP’s three scopes and .mcp.json trust
This is the section most worth clarifying when learningclaude.json, because MCP configuration is spread across different locations and putting it in the wrong place produces a frustrating “I clearly added this but it’s invisible in my other project” experience. Claude Code’s MCP servers have three scopes (as of 2026-05) [1]:
| Scope | Loaded by | Shared with team | Stored in |
|---|---|---|---|
| local (default) | Current project only | No | ~/.claude.json (under that project’s path) |
| project | Current project only | Yes (via version control) | .mcp.json (project root) |
| user | All your projects | No | ~/.claude.json |
claude mcp add, specify scope with --scope (options go before the server name, -- precedes the command) [1]:
.mcp.json project trust: the official documentation states explicitly that, for security, Claude Code requires you to approve a project-scoped server from .mcp.json before using it [1]. Servers awaiting approval show ⏸ Pending approval in claude mcp list; rejected servers show ✗ Rejected. To reset these approval choices, run claude mcp reset-project-choices.
5. Security boundaries and troubleshooting: when to touch it, when not to
Most of the time, leaveclaude.json alone. There are two categories of situations where hand-editing is reasonable, and two where it will break state.
Safe to hand-edit: removing a stale MCP server entry (deleting one key from mcpServers); clearing an incorrect path trust record pointing to a project that has been moved.
Do not hand-edit: bypassing the tool to directly change trust or approval records will put the file state out of sync with what the tool believes; editing an MCP server command without updating its env vars will cause the server to fail at startup while Claude Code still attempts to connect.
MCP troubleshooting order:
Check claude.json or .mcp.json
Look at
~/.claude.json’s projects.<current-project-path>.mcpServers (or .mcp.json) and verify the command path or URL for the server in question.Verify env vars are complete
A stdio server missing an env key (API key or token) will fail to start.
Query status with tool commands
Use
claude mcp list / claude mcp get <name> to inspect status, or use /mcp inside Claude Code to see connection state and tool count [1].projects, or the path does not match. On Windows, pay particular attention to path case, mixing backslashes and forward slashes, and trailing slash inconsistencies — any of these will be treated as a different project, triggering the trust request every time.
Tool comparison
The “tool-maintained state file” and “MCP scope layering” concepts vary considerably in maturity across tools (as of 2026-05; exact paths and keys are subject to each vendor’s current documentation):| Concept | Anthropic Claude (primary) | OpenAI (Codex) | Google (Gemini CLI) | Cursor |
|---|---|---|---|---|
| Tool-maintained state file | ~/.claude.json (MCP registration, trust, tool approvals) [1] | Needs source verification | Needs source verification | Needs source verification |
| MCP server config location | local / user stored in ~/.claude.json; project stored in .mcp.json [1] | MCP section in config.toml (exact keys need source verification) | mcpServers section in settings.json | .cursor/mcp.json (needs source verification) |
| MCP scope layering | local / project / user, three layers [1] | Needs source verification | Needs source verification | Needs source verification |
| Project MCP requires trust approval | Yes, .mcp.json requires approval by default [1] | Needs source verification | Needs source verification | Needs source verification |
MCP is a cross-tool standard; scope models differMCP is an open standard and most agent tools support connecting to MCP servers. The differences lie in “where configuration is stored, whether there is scope layering, and whether project-level servers require forced approval.” Claude Code’s three-layer local / project / user model combined with mandatory
.mcp.json approval is currently the most complete [1]; other tools typically have a single configuration location with weaker or less documented scope and trust models. Entries that cannot be confirmed are marked “needs source verification”; consult each vendor’s official documentation.Hands-on exercises
Read ~/.claude.json and identify the three key sections
Open the file, locate
projects.<one-of-your-project-paths>, and identify the mcpServers underneath (the local-scope servers). Cross-reference with claude mcp list output to confirm the file contents match what the tool believes.Simulate an MCP connection failure and locate it
First back up with
Copy-Item ~/.claude.json ~/.claude.json.bak. Deliberately corrupt the command path of a stdio server, launch Claude Code, and observe its status with /mcp (it should show a failure). Then work through the Section 5 troubleshooting sequence to locate and correct it. Delete the backup once everything is confirmed working.Common pitfalls
Self-check
The bar for passing this unit
- Can you state in one sentence what distinguishes
claude.json(state, written by the tool) fromsettings.json(policy, written by you)? If you want to batch-allow a tool, which file do you edit? - You want an MCP server visible only in a specific project and not shared with the team. Which scope do you use and which file does it live in? What about sharing with the team?
- MCP local scope is stored in
~/.claude.json. What is.claude/settings.local.json? How are the two different? - The trust dialog keeps firing in the same project. Which section of
claude.jsondo you check first? What is the most likely cause on Windows? - You clone an external repo that ships a
.mcp.json. By default, will its servers connect immediately? What setting would cause them to be auto-approved?
Sources and further reading
Factual claims are grounded in official documentation; fast-changing items are annotated as of 2026-05.-
[1] Anthropic, “Connect Claude Code to tools via MCP,” Claude Code Docs. (MCP three scopes local / project / user and storage locations;
~/.claude.json’sprojects.<path>.mcpServersstructure;.mcp.jsonproject-scoped server requires approval,claude mcp reset-project-choices,⏸ Pending approval;claude mcp add --scope; MCP local scope is distinct from settings.local.json; scope priority order) https://code.claude.com/docs/en/mcp (as of 2026-05) -
[2] Anthropic, “Claude Code settings,” Claude Code Docs. (
enableAllProjectMcpServersauto-approves project MCP;enabledMcpjsonServers/disabledMcpjsonServers; managed-layerallowedMcpServers/deniedMcpServers) https://code.claude.com/docs/en/settings (as of 2026-05)