Claude Desktop MCP Setup: Complete Configuration Guide (2026)
Step-by-step Claude Desktop MCP setup: claude_desktop_config.json paths, npx/uvx stdio, Streamable HTTP OAuth connectors, .mcpb bundles, and ENOENT fixes.
Configuring Model Context Protocol (MCP) in Claude Desktop bridges frontier reasoning models to local filesystems, developer databases, git repositories, and remote cloud APIs. Standard chatbot interfaces restrict language models to isolated conversational sessions. By establishing a declarative client-server bridge, developers empower Claude Desktop to discover tools, inspect local directories, and execute shell automation safely.
Key Takeaways
- Local MCP tools register via JSON-RPC 2.0 in
claude_desktop_config.json, while remote cloud endpoints connect through Streamable HTTP and OAuth 2.1 (PKCE) underSettings > Connectors > Add custom connector.- Local servers execute over standard input/output (
stdio) kernel pipes or package into one-click.mcpb(formerly.dxt) Desktop Extensions bundles via@anthropic-ai/mcpb.- Modern Python MCP servers run ephemerally via Astral
uvxin under 50 milliseconds, while Node.js servers execute cleanly throughnpx -y.- Desktop GUI apps do not inherit
.zshrcor.bashrcPATHvariables, making absolute binary paths mandatory to eliminatespawn ENOENTstartup crashes.
What Is Claude Desktop MCP Setup and How Does It Work?
Claude Desktop MCP setup is the process of registering external tool providers within the local Claude client configuration manifest. When configured, Claude Desktop launches each registered server as a child subprocess during application startup and establishes a structured bidirectional communication session.
The JSON-RPC 2.0 Subprocess Architecture
The communication backbone of Claude Desktop relies on JSON-RPC 2.0 messages transmitted across standard input and output pipes. When Claude Desktop boots, it inspects your configuration file and spawns declared server executables as persistent child processes.
Every message exchange follows strict protocol serialization standards. The client sends structured JSON objects containing method names and parameter dictionaries, while the server replies with typed result payloads or standardized error codes.
Because the communication channel operates through standard operating system pipes, neither party requires a network socket or web server. This architectural design keeps latency minimal while isolating server execution from public interfaces.
The Client Handshake and Tool Discovery Lifecycle
During initial startup, Claude Desktop initiates an initialize handshake with each active subprocess to negotiate protocol capabilities. Once the handshake succeeds, the client issues a tools/list request to discover registered tool definitions.
Each tool returns a structured JSON Schema describing its functional parameters, input requirements, and output formats. The host application parses these schemas and injects them directly into the context window of Claude Sonnet 5.5 or Claude Opus 5.5.
When a user prompts Claude with a task requiring external data, the model selects the matching tool and generates an execution payload. The desktop client then forwards the payload to the appropriate subprocess and streams the response back into the conversation.
| Pipeline Stage | Component | Function in Execution Lifecycle |
|---|---|---|
| 1. UI Prompt Evaluation | Claude Desktop Client | Evaluates conversational input and detects required external tools. |
| 2. Reasoning Core | Claude Sonnet 5.5 / Claude Opus 5.5 | Generates a structured tool call payload adhering to server schemas. |
| 3. IPC Transport | JSON-RPC 2.0 (stdio / SSE) |
Transmits serialized JSON frames across operating system pipes or HTTP streams. |
| 4. Subprocess Execution | Local Server (node / python) |
Executes the requested action within local directories or remote APIs. |
| 5. Response Serialization | Standard Error / Output Streams | Delivers typed response payloads back to the Claude Desktop client. |
| 6. Synthesized Output | Interactive Chat Interface | Renders verified results within the conversational thread. |
Why Local Stdio Replaces Generic Webhook Polling
Traditional chatbot integrations rely on polling webhook endpoints or establishing cloud middleware to coordinate external actions. That pattern introduces network latency, authentication tokens stored on remote servers, and complex firewall traversal rules.
Local stdio transports eliminate external dependencies by executing all operations on the developer host machine. The language model gains direct access to private repositories, local SQLite databases, and project workspaces without exposing proprietary data over the internet.
For deeper background on foundational protocol concepts, review our architectural guide covering Model Context Protocol architecture and primitives. Developers can also explore the official Anthropic Model Context Protocol Documentation to examine client implementation specifications.
Configuration File Locations and JSON Schema Structure
The exact path to claude_desktop_config.json depends on the host operating system: ~/Library/Application Support/Claude/claude_desktop_config.json on macOS and %APPDATA%\Claude\claude_desktop_config.json on Windows. Because Claude Desktop runs as a native desktop application, it maintains its local server configuration inside system application support folders.
Figure 1: Anatomy of claude_desktop_config.json highlighting the mcpServers root object, absolute runtime binary path, arguments array, and scoped environment credentials.
Platform-Specific File Paths on macOS, Windows, and Linux
Operating systems manage user application configuration state through distinct directory hierarchies. macOS stores application support manifests within user libraries, while Windows relies on roaming application data paths.
| Operating System | Configuration File Path | Default Command Runner |
|---|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
/opt/homebrew/bin/npx or uvx |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
C:\Program Files\nodejs\npx.cmd |
| Linux (Preview) | ~/.config/Claude/claude_desktop_config.json |
/usr/bin/npx or uvx |
To open the configuration file through the graphical user interface, open Claude Desktop and navigate to Settings > Developer > Edit Config. This shortcut immediately opens the file in your default system text editor. If the file does not exist, Claude Desktop generates a minimal template automatically.
Deconstructing the mcpServers Configuration Object
The configuration file requires a single root JSON object containing the mcpServers dictionary. Each top-level key within mcpServers acts as the human-readable identifier for that specific tool provider within the user interface.
{
"mcpServers": {
"filesystem": {
"command": "/opt/homebrew/bin/npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Projects"
]
},
"github": {
"command": "/opt/homebrew/bin/npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_yourPersonalAccessTokenHere"
}
}
}
}
Every server entry defines a mandatory command string pointing to the executable runner and an optional args array containing CLI flags. An optional env key accepts key-value pairs representing custom environment variables passed to the child process.
Validating JSON Syntax and Preserving Clean Parsing
JSON syntax errors represent the most frequent cause of silent startup failure. Trailing commas after the final array item or dictionary key will cause the desktop JSON parser to reject the entire manifest.
When modifying configuration files manually, validate the text through a linter before restarting the client. Tools like jq or VS Code syntax highlighting verify that brackets match and quotation marks enclose all keys and values correctly.
The Official Model Context Protocol Reference Servers Repository maintains open-source reference implementations for filesystems, databases, and Git repositories. For engineering teams managing sprint tickets and agile workflows, follow our Jira MCP server guide to integrate enterprise backlog tracking.
Step-by-Step Configuration for Node.js and Python MCP Servers
Adding an MCP server to Claude Desktop requires identifying the server’s runtime language, declaring the package execution command, and restarting the desktop client. Both Node.js and Python ecosystems offer ephemeral runners that download and execute packages without polluting global package directories.
Configuring Node.js Servers with NPX
Node.js servers published to npm execute deterministically through the npx package runner. The -y argument instructs npx to skip interactive installation confirmations, which is critical since background subprocesses have no interactive terminal to accept prompts.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Documents/workspace"
]
}
}
}
Verify that Node.js LTS is installed and present in your system PATH before saving the configuration. If your workstation relies on version managers such as NVM or FNM, supply the absolute path to npx to avoid runtime path resolution errors.
Configuring Python MCP Servers with UVX
Deploying Python MCP servers via Astral uvx eliminates manual virtual environment management and conflicting transitive dependencies. Rather than pre-building shared venvs, uvx creates an isolated ephemeral virtual environment, installs dependencies, and boots the target server in under 50 milliseconds.
{
"mcpServers": {
"git-tool": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "/Users/username/Projects/my-repo"]
},
"sqlite-tool": {
"command": "uvx",
"args": ["mcp-server-sqlite", "--db-path", "/Users/username/data/analytics.db"]
}
}
}
The Astral uv Tool Execution Documentation provides detailed performance metrics showing how ephemeral environments prevent dependency drift. For developers interested in writing custom tools in Python, our walkthrough on building custom Python MCP servers with FastMCP explains how to author custom functions with automatic schema generation.
Managing Native Docker MCP Servers Locally
Containerized MCP servers encapsulate complex runtime dependencies like database drivers and system libraries inside lightweight Docker images. Using Docker avoids installing local language runtimes while providing strict resource isolation.
{
"mcpServers": {
"postgres-docker": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"POSTGRES_URL=postgresql://user:password@localhost:5432/production",
"mcp/postgres"
]
}
}
}
The -i flag keeps standard input open for JSON-RPC message streaming, while --rm automatically destroys the temporary container upon exit. Ensure the Docker daemon is running locally before launching Claude Desktop to prevent container initialization timeouts.
[!TIP] Always verify that target directories exist on disk before launching Claude Desktop. If a declared directory in the
argsarray cannot be found, the server subprocess terminates during initial handshake negotiation.
Claude Desktop vs Claude Code: Global Manifests vs Project Scopes
Comparing Claude Desktop against Claude Code CLI reveals fundamental architectural differences in how tool scopes, configuration files, and permissions are managed. While Claude Desktop maintains a single global manifest across all conversations, Claude Code CLI introduces multi-tiered project-scoped configurations that teams can commit directly to source control repositories.
Global Application Scope in Claude Desktop
Claude Desktop operates under a monolithic configuration model. Every tool registered inside claude_desktop_config.json becomes globally available across every chat thread regardless of the current working directory or topic.
This design favors simplicity for desktop users who frequently inspect personal files or run recurring daily utilities. For non-technical teams running desktop task automation across local folder workspaces, review our Claude Cowork architectural guide to evaluate hypervisor sandboxing and local filesystem isolation. However, it can bloat the system prompt context when dozens of servers register hundreds of tool definitions simultaneously.
Large tool inventories consume significant token budgets during every prompt turn. Connecting 6 to 8 global servers routinely registers 80 to 120 JSON tool schemas consuming 12,000 to 18,000 system prompt tokens (roughly 6% to 9% of a 200K context window), adding 150ms to 400ms of prefill latency before responses start streaming.
Local stdio calls still execute across kernel pipes in 1ms to 3ms per hop once initialized, compared to 25ms to 90ms per HTTPS round-trip over remote Streamable HTTP connectors, so pruning unused global servers in claude_desktop_config.json keeps both latency and token overhead minimal.
Hierarchical Project Scopes and .mcp.json in Claude Code
Claude Code CLI introduces a flexible scoping model tailored for engineering repositories. Developers can declare server definitions globally in ~/.claude.json or isolate them within a specific repository using a root .mcp.json file.
| Architectural Feature | Claude Desktop | Claude Code CLI |
|---|---|---|
| Primary Configuration File | claude_desktop_config.json |
~/.claude.json (user) and .mcp.json (project) |
| Configuration Scope | Single global scope for all chats | Hierarchical: user global or git repo project scope |
| Team Git Versioning | Personal machine only (not shared) | Version controlled via root .mcp.json commit |
| Configuration Interface | GUI settings or manual text editor | Interactive /mcp CLI or claude mcp add |
| Migration Utility | Manual schema authoring | Automated claude mcp add-from-claude-desktop |
| Transport Typing | Implicit command detection | Strict explicit type declaration (stdio, http) |
Project-level .mcp.json files allow teams to standardize linters, test runners, and internal documentation searchers across git clones. When a teammate clones the repository, Claude Code reads the local .mcp.json automatically.
{
"mcpServers": {
"repo-linter": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@organization/custom-linter"],
"env": {
"STRICT_MODE": "true"
}
}
}
}
Notice that Claude Code requires an explicit "type": "stdio" property in its schema definitions. Omitting this field triggers schema validation errors during CLI startup.
Migrating Existing Desktop Configurations to Claude Code CLI
Developers moving from the desktop application to the terminal can transfer their configured servers without manual copy-pasting. Claude Code includes built-in CLI commands designed both to ingest desktop manifests and register remote Streamable HTTP connectors directly.
Running claude mcp add-from-claude-desktop reads claude_desktop_config.json and copies registered servers into your user-level ~/.claude.json file. For remote endpoints, teams can also bind hosted URLs and trigger interactive PKCE authentication from the terminal using claude mcp add --transport http <server-name> https://mcp.yourdomain.com/mcp followed by claude mcp login <server-name> (or /mcp inside a session).
This bidirectional compatibility allows engineers to prototype servers within Claude Desktop before deploying them into version-controlled team repositories.
Transport Comparison: Local Stdio IPC vs Remote Streamable HTTP and OAuth
Running a local stdio MCP connection keeps all tool execution on your workstation through standard input and output pipes rather than network sockets. Choosing between local stdio and remote Streamable HTTP (which replaced legacy standalone SSE as the modern remote MCP transport) depends on whether your tools inspect private local repositories or run on multi-tenant cloud infrastructure.
Figure 2: Claude Desktop MCP transport paths comparing local sub-2ms stdio subprocesses against OAuth-authenticated remote Streamable HTTP and SSE endpoints.
Latency Characteristics and OS Kernel Pipe Mechanics
Standard input and output transports use operating system kernel buffers to exchange memory frames directly between parent and child processes. This eliminates network stacks, TLS handshakes, and DNS lookup overhead completely.
Per the Model Context Protocol Transports Specification, local stdio clients operate over direct OS pipes without TCP serialization delays, whereas remote Streamable HTTP transports issue HTTP POST requests with optional server-sent response streams over TLS networks.
Because stdio communication occurs in-memory on the host machine, throughput is limited only by CPU serialization speeds. Local tool calls execute virtually instantaneously, creating a responsive user experience during iterative conversational tasks.
| Architecture Metric | Local Stdio Transport | Remote Streamable HTTP (OAuth 2.1) |
|---|---|---|
| Transport Path | Direct OS stdin/stdout kernel pipes | HTTPS POST (https://.../mcp) + optional stream |
| Execution Host | Spawned child subprocess on workstation | Hosted cloud server or Kubernetes pod |
| Configuration Location | claude_desktop_config.json (command, args) |
Settings > Connectors > Add custom connector |
| Authentication Standard | Host OS file permissions | OAuth 2.1 Authorization Code + PKCE token rotation |
| Session Isolation | Single local OS user session | Per-user isolated OAuth token context |
| Best Used For | Filesystem, SQLite, local Git repos | Shared SaaS tools, cloud APIs, enterprise knowledge bases |
Remote Streamable HTTP Connectors and OAuth 2.1 PKCE
Crucially, remote Streamable HTTP MCP servers do not go inside claude_desktop_config.json. Instead, Claude Desktop integrates remote servers natively through Settings > Connectors > Add custom connector using your server URL (such as https://mcp.yourdomain.com/mcp).
Claude Desktop acts as a public OAuth 2.1 client using Authorization Code flow with PKCE and auto-discovery metadata routes. When you connect a custom connector, Claude opens your system browser for consent, stores rotating short-lived tokens securely, and avoids saving static long-lived API keys inside plaintext JSON manifests.
Meanwhile, legacy standalone SSE setups that predate Streamable HTTP can still be bridged over HTTP headers or mcp-remote, though enterprise firewalls and proxies frequently time out unbuffered event streams unless upgraded to Streamable HTTP.
Architectural Decision Matrix: When to Deploy Stdio vs Streamable HTTP
Use local stdio transports for tools that interact directly with developer workstations, such as code formatters, local file searchers, and development databases. Local subprocesses keep repository files and environment boundaries completely inside your physical machine.
Deploy remote Streamable HTTP connectors when distributed engineering teams share access to managed cloud infrastructure, unified SaaS APIs, or central vector databases. Centralized OAuth connectors enforce token expiration and per-user authorization policies without distributing static config secrets to laptops.
For browser automation and end-to-end testing workflows running on your local machine, review our comprehensive Playwright MCP browser automation setup guide.
Desktop Extensions GUI vs Manual JSON Configuration
Recent releases of Claude Desktop introduced Desktop Extensions, providing a graphical catalog for installing vetted MCP servers without editing JSON files directly. Choosing between extension installs and manual JSON editing depends on your workflow requirements.
One-Click Packaging and CLI Distribution with .mcpb Bundles
Desktop Extensions package server executables, a manifest.json declaration, runtime assets, and icon metadata into unified .mcpb archives (originally introduced under .dxt and standardized as MCP Bundles). End users install them from Settings > Extensions > Browse extensions, or drag and drop a downloaded .mcpb archive directly onto the Settings panel.
For tool authors distributing servers internally or publicly, Anthropic ships the official packaging CLI (@anthropic-ai/mcpb):
# Install the MCPB packaging toolchain and bundle a local server
npm install -g @anthropic-ai/mcpb
mcpb init
mcpb pack
The graphical interface displays structured permission consent dialogues before enabling bundled tools, letting users inspect requested directory boundaries or API fields without editing raw configuration manifests.
Enterprise Administrative Governance and Deployment Policies
For corporate workspaces, Desktop Extensions offer centralized administrative controls through Anthropic enterprise management consoles. IT administrators can define allowlists of permitted extensions and block unverified external servers.
Centralized policy distribution ensures that enterprise security standards remain consistent across employee workstations. Organizations can enforce minimum authentication standards and restrict local file access boundaries globally.
Telemetry dashboards allow security officers to audit tool invocation frequencies and track enterprise API consumption. These compliance features make extensions attractive for regulated business environments.
| Selection Factor | Desktop Extensions (.mcpb GUI) | Manual JSON Configuration |
|---|---|---|
| Installation Interface | In-app directory or .mcpb drag-and-drop |
Text editor modification of JSON |
| Custom Binary Paths | Bundled runtime inside archive | Fully customizable absolute paths |
| Private Internal Servers | Supported via internal .mcpb distribution |
Fully supported via local scripts |
| Custom Environment Variables | Guided manifest form fields | Flexible JSON env dictionary |
| Target Audience | General practitioners and SaaS users | Software engineers and systems architects |
When Senior Systems Architects Must Retain Manual JSON
Despite the convenience of .mcpb extensions, software engineers and infrastructure architects still rely on manual JSON configuration for rapid iteration. Unpackaged prototypes, custom Rust or Go binaries under active compilation, and per-workstation CLI flag experiments remain faster to test directly inside claude_desktop_config.json.
For an extensive directory of pre-built integrations, explore our curated guide to the top Claude MCP server integrations.
Production Troubleshooting: Fixing Spawn ENOENT and Stderr Corruption
Effective MCP troubleshooting in Claude Desktop begins by isolating GUI PATH inheritance failures from standard output stream pollution. Understanding how Claude Desktop spawns child subprocesses resolves nearly all startup crashes.
Resolving Spawn ENOENT via Absolute Binary Discovery and NVM Fixes
The spawn ENOENT error indicates that Claude Desktop attempted to execute a command specified in claude_desktop_config.json but could not find the binary on disk. This issue occurs because desktop GUI applications do not inherit interactive terminal shell profiles like .zshrc or .bashrc.
Operating system launch daemons execute applications with a restricted default PATH containing only core system directories, leaving Homebrew, nvm, fnm, and Astral uv binaries invisible unless resolved to an absolute path.
On nvm-managed macOS or Linux machines, Node version bumps rotate versioned subfolders and break hardcoded paths; symlinking your active npx binary into /usr/local/bin/npx (or pointing to a fixed system LTS install) prevents silent breaks after updates. This macOS permission and PATH pattern also applies when wiring local knowledge tools like the Apple Notes MCP setup guide.
# Locate absolute binary paths on macOS and Linux
which npx
# Expected output: /opt/homebrew/bin/npx or /usr/local/bin/npx
which uvx
# Expected output: /Users/username/.local/bin/uvx
On Windows workstations, open PowerShell and discover the full executable path using where.exe or Get-Command:
# Locate binary paths on Windows systems
where.exe uvx
Get-Command npx | Select-Object -ExpandProperty Source
Replace shorthand command names with discovered absolute paths inside claude_desktop_config.json. On Windows hosts using nvm-windows or Node shims where direct .cmd spawning fails, wrap npx-cli.js cleanly via cmd.exe /c:
{
"mcpServers": {
"filesystem-macos": {
"command": "/opt/homebrew/bin/npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Documents"
]
},
"filesystem-windows-nvm": {
"command": "cmd.exe",
"args": [
"/c",
"C:\\Users\\username\\AppData\\Roaming\\nvm\\v22.14.0\\node_modules\\npm\\bin\\npx-cli.js",
"-y",
"@modelcontextprotocol/server-filesystem",
"C:\\Users\\username\\Documents"
]
}
}
}
Eliminating Stdout JSON-RPC Framing Corruption with Stderr Logging
The MCP stdio transport requires that standard output (stdout) be reserved strictly for newline-delimited JSON-RPC 2.0 frames. If a custom script or imported third-party library writes debugging statements or warnings to stdout, the message stream is immediately corrupted, forcing Claude Desktop to drop the connection.
import sys
# BROKEN: Writing raw text to stdout corrupts JSON-RPC framing
# print("Debug: Initializing server configuration")
# CORRECT: Direct all diagnostic logs to stderr
sys.stderr.write("Debug: Initializing server configuration\n")
sys.stderr.flush()
The Model Context Protocol Debugging Guide emphasizes that all diagnostic logging, progress reports, and traceback outputs must route to standard error (stderr). Claude Desktop captures stderr output and writes it directly to mcp-server-{servername}.log inside your system log directory without disrupting active tool calls.
Inspecting System Debug Logs on macOS and Windows
When a server fails to initialize, real-time diagnostic logs provide detailed stack traces and process exit codes. Monitoring these logs in terminal windows accelerates troubleshooting during configuration testing.
On macOS, open Terminal and stream real-time logs using tail:
tail -n 50 -f ~/Library/Logs/Claude/mcp.log
On Windows, inspect logs using PowerShell:
Get-Content "$env:APPDATA\Claude\logs\mcp.log" -Tail 50 -Wait
Individual server output logs reside in the same folder under the naming format mcp-server-{servername}.log. Checking these specific log files reveals dependency import errors and unhandled runtime exceptions.
[!IMPORTANT] Always completely quit Claude Desktop before testing configuration changes. Minimizing the application window leaves background child processes running with old configuration values in memory.
Security Best Practices and Credential Management for Local MCP
Registering MCP servers grants Claude Desktop your active operating system user permissions across host filesystems and connected remote APIs. Because Anthropic does not sandbox or audit arbitrary third-party community servers launched locally, enforcing tight defense-in-depth boundaries is mandatory.
Mitigating Indirect Prompt Injection Across Connected Tools
When Claude Desktop reads external content via a web fetcher, GitHub issue server, email connector, or untrusted repository file, raw payloads return directly into the model context window. If an adversarial comment or document embeds hidden instructions such as reading ~/.ssh/id_rsa or claude_desktop_config.json and exfiltrating secrets over a web request, an over-privileged tool chain can bridge untrusted text straight to local filesystem compromise.
Always combine narrow directory allowlists with strict human-in-the-loop tool confirmation modes so destructive commands, secret-adjacent reads, and outbound network requests require explicit approval.
Enforcing Directory Sandboxing and Least Privilege Access
Filesystem servers should always adhere to the principle of least privilege. Never pass your root drive (/ or C:\) or entire home directory (~) as directory arguments.
Restrict directory arguments to dedicated workspace folders containing only the files relevant to your project. Sandboxing directory boundaries prevents the language model from inadvertently inspecting configuration files, SSH keys, or system binaries.
Securing Plaintext Tokens with Keychain Stores and chmod 600 Permissions
Because claude_desktop_config.json stores local env keys in plaintext, any cloud-sync tool, dotfile backup repo, or indirect prompt-injection read can expose hardcoded credentials. Prefer remote OAuth 2.1 connectors whenever available, pull local developer secrets dynamically from OS credential stores (such as macOS Keychain via security find-generic-password or Windows Credential Manager), and lock configuration file permissions strictly to your user account:
# Restrict file permissions to the current owner on macOS and Linux
chmod 600 ~/Library/Application\ Support/Claude/claude_desktop_config.json
Setting chmod 600 ensures that other local user accounts and unprivileged background services cannot read your stored configuration manifest. Never commit personal configuration files containing raw tokens to public or shared Git repositories.
{
"mcpServers": {
"postgres-readonly": {
"command": "/opt/homebrew/bin/npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://readonly_role@localhost:5432/analytics"]
}
}
}
Configuring Read-Only Database Guards and Query Limits
When exposing database servers to conversational AI, always create dedicated read-only database roles. Restrict database user privileges to SELECT operations and explicitly revoke INSERT, UPDATE, DELETE, and DROP permissions.
Configure statement timeout limits and maximum row thresholds on the database server to prevent runaway analytical queries. Unbounded queries can exhaust host memory and degrade database responsiveness during long-context analysis sessions.
For comprehensive architectural patterns on securing relational databases, follow our MCP database integration tutorial for PostgreSQL and SQLite to configure connection pooling and query safeguards.
Frequently Asked Questions
Where is the Claude Desktop MCP configuration file located on Mac and Windows?
On macOS, the configuration file is located at ~/Library/Application Support/Claude/claude_desktop_config.json, whereas on Windows it resides at %APPDATA%\Claude\claude_desktop_config.json. You can open it directly from the Claude Desktop interface by navigating to Settings, selecting Developer, and clicking Edit Config.
Why does Claude Desktop fail with “spawn ENOENT” when starting an MCP server?
Claude Desktop is launched as a GUI process that does not inherit interactive shell environment variables like PATH defined in your .zshrc or .bashrc profile. Resolve this by using the absolute binary path (/opt/homebrew/bin/npx or /Users/username/.local/bin/uvx), symlinking nvm binaries into /usr/local/bin/, or wrapping npx-cli.js inside cmd.exe /c on Windows.
How do you configure Python MCP servers in Claude Desktop using uvx?
Set the command field to the absolute path of uvx and pass the Python package name and any server flags inside the args array within claude_desktop_config.json. This approach eliminates manual virtual environment management by allowing Astral uv to isolate dependencies and launch the server in under 50 milliseconds.
How does Claude Desktop MCP configuration differ from Claude Code MCP?
Claude Desktop stores local server configurations in a single global manifest (claude_desktop_config.json) that activates across every chat session. In contrast, Claude Code supports multi-layered configurations including project-scoped .mcp.json files checked into Git repositories alongside user-level ~/.claude.json files and claude mcp add-from-claude-desktop import tooling.
Can Claude Desktop connect to remote MCP servers over Streamable HTTP and OAuth?
Yes. Remote Streamable HTTP servers (https://.../mcp) with OAuth 2.1 PKCE login connect directly inside Claude Desktop under Settings > Connectors > Add custom connector rather than claude_desktop_config.json. Keep claude_desktop_config.json strictly for local stdio subprocesses or legacy header-authenticated endpoints.
What are Claude Desktop .mcpb extensions and how do they differ from manual JSON configuration?
Desktop Extensions package a server binary, runtime assets, and manifest.json into a one-click .mcpb bundle (formerly .dxt) installed via Settings > Extensions or built with @anthropic-ai/mcpb (mcpb init and mcpb pack). Manual configuration in claude_desktop_config.json remains necessary when iterating on local unpackaged scripts, custom compiled binaries, or bespoke environment flags.
Why does an MCP server disconnect when writing logs to stdout?
The MCP stdio transport relies strictly on newline-delimited JSON-RPC 2.0 messages across standard output, meaning raw text or print() statements corrupt the message stream. Developers must route all debugging and informational log output to standard error (stderr) to preserve client-server communication.
How do discovery prompts and installation permissions work in Claude Desktop MCP?
When Claude Desktop initializes, it sends an initialize handshake and a tools/list request to discover active tool schemas (for local stdio manifests or .mcpb bundles), or performs OAuth 2.1 consent and scope approval for remote connectors. Users should audit workspace paths, verify hammer-menu tool scopes, and keep manual confirmation enabled before running state-changing actions.