Skip to content

MCP Setup and Installation: Claude Desktop and Claude Code

This tutorial gets you from zero to a working MCP setup in under 10 minutes.

Prerequisites

  • Node.js 18+ or Python 3.11+
  • Claude Desktop (for local testing) or Claude Code CLI

Node.js is required for most official MCP servers, which are distributed as npm packages. Even if your own MCP servers are Python-based, you’ll likely need Node.js for the official servers in the ecosystem.

Option A: Claude Desktop (GUI)

1. Install Claude Desktop

Download and install Claude Desktop from the Anthropic website.

2. Configure MCP Servers

Claude Desktop reads MCP configuration from a JSON file. To open it, click the Claude menu in your system’s menu bar, select Settings…, open the Developer tab, and click Edit Config.

The file is at:

macOS:

Terminal window
~/Library/Application Support/Claude/claude_desktop_config.json

Windows:

%APPDATA%\Claude\claude_desktop_config.json

Linux:

Terminal window
~/.config/Claude/claude_desktop_config.json

3. Add a Server

Here’s an example adding the official filesystem MCP server:

{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/you/Documents"
]
}
}
}

Replace /Users/you/Documents with the directory you want Claude to have access to. The filesystem server restricts access to the specified path — Claude won’t be able to read or write files outside that directory.

The command and args array tells Claude Desktop how to start the server. Claude Desktop will run npx -y @modelcontextprotocol/server-filesystem /Users/you/Documents as a subprocess when you open a chat session.

4. Restart Claude Desktop

Completely quit and restart Claude Desktop after saving the config. Then click the Add files, connectors, and more button in the chat input, hover over Connectors, and click Manage connectors. Your server should be in the list, and selecting it shows its tools.

If it doesn’t appear, or if it shows fewer tools than expected, check the troubleshooting section below.

5. Verify the Setup

In a new chat session, ask Claude: “What tools do you have access to?” It should list the tools exposed by your configured servers. For the filesystem server, you should see tools like read_text_file, write_file, list_directory, and others.

Option B: Claude Code CLI

Add servers to Claude Code with the claude mcp add command. Its --scope option sets where the server is stored and who gets it:

ScopeStored inApplies to
local (default)~/.claude.json, under the project’s pathYou, in this project
project.mcp.json in your project rootEveryone on the project, through version control
user~/.claude.jsonYou, in all projects

Most developers use project scope for tools the whole team needs (filesystem, project database) and user scope for universal tools (web search, memory).

Project scope

From your project root, run:

Terminal window
claude mcp add --scope project --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem .

Everything after -- is the command that starts the server. This creates a .mcp.json file you can commit:

{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}

The "." path for the filesystem server grants access to the current directory (your project root). This is a common pattern for development workflows where Claude needs to read and write project files.

Claude Code asks you to approve servers from a .mcp.json file before it uses them.

User scope

Terminal window
claude mcp add --scope user --transport stdio memory -- npx -y @modelcontextprotocol/server-memory

The memory server is a good candidate for user scope because you generally want persistent memory available across all Claude Code sessions, not just in specific projects.

Verify it’s working

Terminal window
# List configured servers and their connection status
claude mcp list

This command shows each server with a status such as ✔ Connected or ✘ Failed to connect. Inside a Claude Code session, run /mcp to see each server’s status and tool count.

Transport Types

MCP defines two standard transports:

TransportUse Case
stdioLocal servers (most common) — server runs as a subprocess
Streamable HTTPRemote servers — server runs as an HTTP service

stdio config (local subprocess):

{
"command": "python",
"args": ["my_server.py"]
}

The command and args fields are required for stdio transport. Claude Desktop or Claude Code will spawn this process when starting a session.

Streamable HTTP in Claude Code (remote server):

Terminal window
claude mcp add --transport http notion https://mcp.notion.com/mcp

In a .mcp.json file, the same server looks like this. The type field is required, because Claude Code rejects a url entry without one:

{
"mcpServers": {
"notion": {
"type": "http",
"url": "https://mcp.notion.com/mcp"
}
}
}

Instead of spawning a subprocess, the MCP client connects to the specified URL. This is useful for server-side deployments where the MCP server is running independently. In Claude Desktop, the config file examples above cover local servers only. See the guide to connecting remote servers for that app.

Adding Environment Variables

Pass API keys and config to MCP servers via the env field:

{
"mcpServers": {
"my-server": {
"command": "python",
"args": ["server.py"],
"env": {
"API_KEY": "sk-...",
"DATABASE_URL": "postgresql://..."
}
}
}
}

The env field merges with the process environment. Variables you specify here are available to the server process as environment variables.

For local development, the env field in the config is convenient. For production or shared environments, use environment variables set in your shell or a secrets manager, and access them in the server code via os.environ.

In a .mcp.json file, Claude Code expands ${VAR} and ${VAR:-default}, so you can commit the file without committing the secret:

{
"mcpServers": {
"my-server": {
"command": "python",
"args": ["server.py"],
"env": { "API_KEY": "${MY_SERVER_API_KEY}" }
}
}
}

Configuring Multiple Servers

You can run multiple servers simultaneously:

{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
},
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
},
"database": {
"command": "python",
"args": ["db_server.py"],
"env": { "DATABASE_URL": "postgresql://..." }
}
}
}

All servers in the config start when you open a Claude session. The model has access to all tools from all servers and decides which to call based on the task.

Keys in the mcpServers object are server names — they’re used for display purposes and in logs. Choose names that identify the server’s purpose clearly.

Troubleshooting

Server not appearing in Claude Desktop:

  • Check the config file is valid JSON: python3 -m json.tool < config.json
  • Ensure the command is in your PATH: run which npx or which python3
  • Check Claude Desktop logs: ~/Library/Logs/Claude/ (macOS), %APPDATA%\Claude\logs\ (Windows), or ~/.config/Claude/logs/ (Linux). mcp.log covers connections, and mcp-server-SERVERNAME.log holds each server’s stderr.

Server crashes immediately:

  • Run the server command manually in your terminal to see error output
  • Check the server’s dependencies are installed (try npm install or pip install)
  • Verify the arguments are correct — paths must exist, API keys must be valid

Server loads but tools don’t work:

  • Test the server directly with the MCP inspector: npx @modelcontextprotocol/inspector <command> <args>
  • Check that the required environment variables are set
  • Look at the server’s logs (written to stderr by convention)

claude mcp list shows no servers:

  • MCP servers don’t go in .claude/settings.json. Add them with claude mcp add or in .mcp.json
  • Check that .mcp.json is valid JSON and sits in your project root
  • Verify you’re running Claude Code from the correct project directory, since local and project servers only apply there
  • A status of Pending approval means Claude Code hasn’t been allowed to use a .mcp.json server yet. Run claude to approve it

Security Considerations

MCP servers can read files, query databases, make HTTP requests, and take other actions on your behalf. Before adding any MCP server, consider:

  • What can it access? Check the server’s documentation and source code to understand what data it can read.
  • What can it write? Some servers can write or delete data. Understand the blast radius if the server behaves unexpectedly.
  • Where does the data go? Does the server send data to external services? Is that appropriate for your data?
  • Who maintains it? Check that the project is still maintained, since even some official reference servers have been deprecated. Community servers vary. Review the source before adding.

The filesystem server is worth special attention: specify the minimum directory necessary, not your entire home directory. A server with access to / on your system can read any file you have access to.

Next Steps