AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure MCP in Claude Desktop to Connect Local Databases and Developer Tools

白川裕亮 · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Running Claude Desktop in an isolated sandbox is reassuring for security, but frustrating when you are debugging complex systems. For months, engineers endured an exhausting dance: run a query in psql, dump a CSV, redact sensitive columns, drag the file into the chat window, ask a question, spot an anomaly, and repeat. Context was fragmented. Feedback loops crawled.

The release of the Model Context Protocol (MCP) by Anthropic changed this paradigm. By providing an open JSON-RPC specification over standard input/output (stdio), Claude Desktop can directly communicate with local processes running on your workstation. With the right configuration, Claude can inspect relational schemas, execute analytical queries against PostgreSQL or SQLite, and navigate local codebases in real time.

At 365Finds, our testing shows that MCP transforms Claude Desktop from an isolated conversational assistant into an indispensable engineering co-pilot. Direct local integration requires zero-trust discipline. If you mount arbitrary root paths or feed a read-write database superuser string to an LLM, you are asking for unintended side effects. Here is how to configure local MCP servers properly, avoid the operating system path traps that stall most setups, and establish robust security guardrails.


How Claude Desktop MCP Integration Works

Claude Desktop functions as an MCP Host. When you launch the application, it reads a central JSON configuration file, spawns the MCP servers you have defined as sub-processes, and communicates with them via stdio.

+-----------------------------------------------------------+
|                      Claude Desktop                       |
|               (MCP Client / LLM Host Engine)              |
+-----------------------------+-----------------------------+
                              | stdio (JSON-RPC)
        +---------------------+---------------------+
        |                                           |
+-------v-------------------+       +---------------v-----------+
|    Local Database Server  |       |  Local Filesystem Server  |
|  (PostgreSQL / SQLite)    |       |   (Scoped Directories)    |
+---------------------------+       +---------------------------+

Every MCP server exposes three fundamental primitives:

  1. Tools: Executable routines Claude can invoke (such as executing a SQL SELECT statement or listing files).
  2. Resources: Read-only data streams Claude can inspect (such as file contents or schema definitions).
  3. Prompts: Pre-defined templates configured by the server.

Whenever Claude decides to query a table or read a file, it does not do so silently. The interface prompts you to inspect and approve the tool call and its arguments, ensuring you retain deterministic control over execution.


Locating Your Configuration File

Claude Desktop looks for an orchestrating file named claude_desktop_config.json. The fastest way to access it is through the GUI: click the application menu, select Settings (or press Cmd+, / Ctrl+,), navigate to the Developer tab, and click Edit Config.

If you prefer navigating from the terminal, the platform-specific paths are:

Operating SystemAbsolute Configuration Path
macOS~/Library/Application Support/Claude/claude_desktop_config.json
Windows%APPDATA%\Claude\claude_desktop_config.json
Linux~/.config/Claude/claude_desktop_config.json

If the file does not exist, creating it with an empty root object { "mcpServers": {} } is all you need to get started.


Step 1: Mounting the Local Filesystem Server

The official @modelcontextprotocol/server-filesystem package grants Claude structured access to read directories, inspect files, and search file content.

Because Claude Desktop manages Node-based servers through npx, Node.js (LTS version recommended) must be installed on your workstation.

Configuration

Add the filesystem entry to mcpServers inside claude_desktop_config.json:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/devuser/Projects/core-api",
        "/Users/devuser/Documents/specs"
      ]
    }
  }
}

For Windows, use escaped backslashes in paths (for example, C:\\Users\\devuser\\Projects\\core-api).

365Finds Security Recommendation: Directory Scoping

Never pass your root directory (/), your entire home directory (/Users/devuser), or system directories into args. The filesystem MCP server runs under your personal OS user permissions. If you grant broad scope, any prompt injection or unintended hallucinated script could read personal SSH keys, shell history, or sensitive environment files (.env). Restrict folder arguments strictly to the active repository or documentation directory you are investigating.


Step 2: Connecting Local Databases

Connecting a database lets Claude inspect relational schemas, discover foreign key dependencies, and query operational data without sending raw datasets to external third-party cloud aggregators.

Option A: PostgreSQL via Node.js (npx)

Anthropic provides @modelcontextprotocol/server-postgres for connecting directly to PostgreSQL instances:

{
  "mcpServers": {
    "postgres-local": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://claude_analyst:SecurePass123!@localhost:5432/analytics_db"
      ]
    }
  }
}

Crucial Database Security: Dedicated Read-Only Roles

We strongly advise against using your default postgres superuser credentials in claude_desktop_config.json. Claude can write valid SQL, but an errant query could lock production tables or inadvertently run destructive updates. Create an isolated read-only user inside PostgreSQL:

-- Create an isolated analyst role
CREATE ROLE claude_analyst WITH LOGIN PASSWORD 'SecurePass123!';
GRANT CONNECT ON DATABASE analytics_db TO claude_analyst;

-- Grant schema navigation and read-only query permissions
GRANT USAGE ON SCHEMA public TO claude_analyst;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO claude_analyst;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO claude_analyst;

-- Prevent runaway queries from exhausting local connection pools
ALTER ROLE claude_analyst SET statement_timeout = '8000ms';

Setting a strict statement_timeout prevents Claude from locking up your database should it generate an unindexed Cartesian product across multi-gigabyte tables.

Option B: SQLite via Python (uvx)

If your project utilizes SQLite or embedded databases, Astral's uvx (part of the ultra-fast Python package manager uv) offers the cleanest way to run mcp-server-sqlite:

{
  "mcpServers": {
    "sqlite-local": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/Users/devuser/Projects/core-api/dev_database.sqlite"
      ]
    }
  }
}

Step 3: Injecting Environment Variables Cleanly

Passing API keys or dynamic credentials directly inside args can expose them to operating system process listing utilities (like ps aux). To protect sensitive variables, use the dedicated "env" object within the server definition:

{
  "mcpServers": {
    "custom-dev-tools": {
      "command": "npx",
      "args": [
        "-y",
        "@custom-org/mcp-internal-gateway"
      ],
      "env": {
        "API_GATEWAY_TOKEN": "internal_sec_token_98234",
        "INTERNAL_ENV": "staging"
      }
    }
  }
}

Environment variables declared here are cleanly injected into the spawned child process without leaking into system command lines.


Troubleshooting Common MCP Traps

Even experienced developers encounter initialization failures when configuring Claude Desktop. Most issues stem from desktop application process environments differing from interactive shell sessions.

1. The macOS GUI PATH Trap (spawn npx ENOENT / command not found)

This is the single most common stumbling block. When you run npx or uvx in your terminal, your shell reads paths from ~/.zshrc or ~/.bash_profile (including Homebrew paths like /opt/homebrew/bin or NVM shims).

However, when Claude Desktop launches from /Applications or macOS Spotlight, it is spawned by launchd as a GUI process. It only inherits the bare system PATH (/usr/bin:/bin:/usr/sbin:/sbin). It cannot find npx or uvx.

The Solution: Replace the short command name with the full absolute path to the binary. Find the path in your terminal:

which npx
# Outputs: /opt/homebrew/bin/npx (Apple Silicon) or /usr/local/bin/npx (Intel)

which uvx
# Outputs: /Users/devuser/.cargo/bin/uvx

Update your configuration:

{
  "mcpServers": {
    "filesystem": {
      "command": "/opt/homebrew/bin/npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/devuser/Projects/core-api"
      ]
    }
  }
}

Alternatively, inject an explicit PATH inside the "env" block:

"env": {
  "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
}

2. Windows Path Escaping and ${APPDATA} Errors

On Windows, single backslashes in JSON configuration files cause silent parsing errors. Always escape backslashes (C:\\path\\to\\dir).

Furthermore, if your server log throws an error referencing ${APPDATA} literally, Claude Desktop is failing to expand the environment variable. Add the explicit path to your "env" dictionary:

"env": {
  "APPDATA": "C:\\Users\\devuser\\AppData\\Roaming"
}

3. Reading Claude Desktop MCP Logs

When a server fails to connect or the hammer icon does not show up, do not guess. Inspect the runtime logs directly:

The two critical log files are:

On macOS or Linux, stream the logs in real time while restarting Claude Desktop:

tail -n 50 -f ~/Library/Logs/Claude/mcp*.log

On Windows PowerShell:

Get-Content "$env:APPDATA\Claude\logs\mcp*.log" -Tail 50 -Wait

Verifying Tool Connectivity

After updating claude_desktop_config.json, completely quit and relaunch Claude Desktop. Closing the main window alone leaves the background process running. On macOS, use Cmd+Q; on Windows, exit via the system tray icon.

Once relaunched:

  1. Open a new chat.
  2. Look at the lower edge of the prompt input bar. You will see a connector/hammer icon indicating active MCP connections.
  3. Click the icon to view the full registry of available tools (such as read_file, list_directory, query, or describe_table).
  4. Prompt Claude: "Inspect the tables in our connected database and show me the schema of recent user events."

Claude will generate a tool call proposal. Once you click Approve, it will execute the query locally, receive structured JSON results over stdio, and synthesize the architectural answer directly in your conversation.

References