AI News HubLIVE
In-site rewrite6 min read

How to connect MCP servers with Claude (Claude desktop and Claude Code)

Learn how to connect MCP (Model Context Protocol) servers to Claude Desktop and Claude Code, enabling Claude to interact with external tools, files, databases, and more. This guide covers the MCP architecture, step-by-step setup for both platforms, including one-click Desktop Extensions and JSON config, as well as CLI commands for Claude Code.

SourceAnalytics VidhyaAuthor: Sree Vamsi

-->

How to Connect MCP Servers to Claude (Desktop & Code)

India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

d

:

h

:

m

:

s

Career

GenAI

Prompt Engg

ChatGPT

LLM

Langchain

RAG

AI Agents

Machine Learning

Deep Learning

GenAI Tools

LLMOps

Python

NLP

SQL

AIML Projects

Reading list

How to Become a Data Analyst in 2025: A Complete RoadMap

A Comprehensive Learning Path to Tableau in 2025

A Comprehensive NLP Learning Path 2025

Learning Path to Become a Data Scientist in 2025

Step-by-Step Roadmap to Become a Data Engineer in 2025

A Comprehensive MLOps Learning Path: 2025 Edition

Roadmap to Become an AI Engineer in 2025

A Comprehensive Learning Path to Master Computer Vision in 2025

Best Roadmap to Learn Generative AI in 2025

GenAI Roadmap for Enterprises

Large Language Models Demystified: A Beginner’s Roadmap

Learning Path to Become a Prompt Engineering Specialist

How to connect MCP servers with Claude (Claude desktop and Claude Code)

Sree Vamsi Last Updated : 17 Jul, 2026

10 min read

Connecting MCP servers to Claude allows it to work with external tools, files, databases, repositories, and other systems instead of operating only within the chat window. The setup differs slightly between Claude Desktop and Claude Code, but both can be configured in just a few steps.

In this article, you’ll learn how to connect MCP servers with Claude Desktop and Claude Code, a practical step-by-step guide for getting each setup running correctly.

Table of contents

What Is MCP and Why Does It Matter?

How MCP Works in 3 Simple Parts

Claude Desktop: Step-by-Step MCP Setup

Method 1: Desktop Extensions (One-Click, No JSON)

Method 2: JSON Config (Full Control)

Editing the Config File

What’s happening in each of the three servers:

Claude Code: Adding MCP Servers via CLI

Adding a Server with claude mcp add

The Best MCP Servers to Install First

Common Errors and Fixes

Advanced: Build Your Own MCP Server

Frequently Asked Questions

What Is MCP and Why Does It Matter?

MCP (Model Context Protocol) is the universal connector layer that lets any AI model talk to any external tool through a single standardised interface without custom integration code for every combination.

Before MCP, connecting Claude to GitHub required one custom integration. Connecting it to Slack required a different one. Connecting it to your database required a third. Anthropic called this the “N×M problem”: N AI models times M external tools meant N×M bespoke connectors. MCP solves it by turning that into N+M. Build one MCP server for GitHub, and every MCP-compatible AI client Claude, Cursor, Windsurf, and dozens more can use it immediately.

How MCP Works in 3 Simple Parts

Understanding the 3-part architecture takes 2 minutes and prevents 90% of setup confusion.

Component What It Is Example in Claude

Host The AI app the user talks to, manages context, security, and which servers are available. Claude Desktop, Claude Code, Cursor

Client Lives inside the host. Handles protocol-level communication with each MCP server. Built into Claude Desktop / Claude Code

Server An external process that exposes tools, resources, or prompts to the AI via MCP. GitHub MCP server, Filesystem MCP server

When you ask Claude to “check my open GitHub PRs”, here is what happens behind the scenes:

Claude identifies it needs an external tool to fulfil the request.

The MCP client in Claude sends a JSON-RPC request to the GitHub MCP server.

The server queries GitHub’s API and returns structured data.

Claude incorporates that data into its context and generates your answer.

The whole flow takes under a second. You never see the plumbing.

As of April 2026, Streamable HTTP is Anthropic’s official recommended transport, and the older SSE transport is being deprecated.

Claude Desktop: Step-by-Step MCP Setup

Claude Desktop reads its MCP configuration from a single JSON file. There are two ways to install servers: the new one-click Desktop Extensions (.mcpb files, formerly .dxt) and the traditional JSON config method. Use Extensions for supported servers; use JSON config for anything custom.

Method 1: Desktop Extensions (One-Click, No JSON)

As of early 2026, Claude Desktop supports Desktop Extensions, pre-packaged MCP servers distributed as .mcpb files (MCP Bundle; older guides may call these .dxt files, which still work but are the legacy name). These install with a double-click. No JSON editing, no Node.js PATH issues.

Open Claude Desktop.

Click the “+” button in the bottom-left of the chat input.

Select “Connectors” to open the connectors menu.

Find your server (e.g., GitHub, Google Drive) and click Install (or Click onn add connectors to find one on the connectors directory).

Restart Claude Desktop. The server activates automatically.

Desktop Extensions are the right choice for non-technical users or servers you want to “set and forget.” The JSON config method below is right for custom servers, private servers, or full control over arguments and environment variables.

Method 2: JSON Config (Full Control)

Claude Desktop reads its MCP configuration from claude_desktop_config.json. The file location depends on your OS:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

On Windows, which folder actually has this file depends on how you installed Claude Desktop, and this trips up a lot of people. There are two completely different locations:

Direct .exe installer (from claude.ai/downloads): %APPDATA%\Claude\claude_desktop_config.json

Microsoft Store, WinGet, or MSIX install: %LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Roaming\Claude\claude_desktop_config.json

If %APPDATA%\Claude doesn’t exist on your machine, you almost certainly have the Store/MSIX install, and your real file is at that second, uglier path. Windows’ app-packaging model silently redirects it there instead of the standard location every piece of documentation assumes.

If neither path has the file yet, open Claude Desktop itself, go to Settings → Developer → Edit Config. That creates the file at whichever path your specific install actually uses, so you don’t have to guess.

One Windows-specific trap: paths inside JSON need double backslashes. C:\Users\yourname\Documents in a JSON string must be written as C:\\Users\\yourname\\Documents, a single backslash breaks the JSON parser. Here’s what a complete, correctly escaped config looks like:

Editing the Config File

Open Claude Desktop → top menu bar → Settings → Developer → Edit Config. This opens the file in your default editor and creates it if it does not exist.

The file has just one top-level key, mcpServers. Think of it as a list of servers you want Claude to know about. Each server gets its own entry inside that list, and you pick whatever name you want for that entry (like “filesystem” or “github” below).

Inside each server’s entry, there are three things you can set:

command: the actual program Claude runs to start that server (usually npx, since most servers are distributed as npm packages)

args: the list of arguments passed to that command, exactly like you’d type them in a terminal

env: any environment variables the server needs, most commonly API keys or access tokens

Here’s a practical starter config for a developer workflow: filesystem access, GitHub integration, and web search:

{ "mcpServers": { "filesystem": { "command": "/usr/local/bin/npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/yourname/Documents", "/Users/yourname/projects"] }, "github": { "command": "/usr/local/bin/npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here" } }, "brave-search": { "command": "/usr/local/bin/npx", "args": ["-y", "@modelcontextprotocol/server-brave-search"], "env": { "BRAVE_API_KEY": "your_brave_api_key" } } } }

What’s happening in each of the three servers:

filesystem doesn’t need any credentials, so it only has command and args. The args list tells npx which package to run (@modelcontextprotocol/server-filesystem) and which folders on your computer it’s allowed to touch, in this case Documents and projects.

github needs to prove who you are to GitHub’s API, so it has an extra env block. GITHUB_PERSONAL_ACCESS_TOKEN is where you paste your own GitHub token. The server reads it as an environment variable when it starts up, the same way a program run from your terminal would.

Getting a GitHub token, step by step:

Go to github.com and sign in. Click your profile photo in the top-right corner, then click Settings.

In the left sidebar, click Developer settings (it’s near the bottom).

Click Personal access tokens, then Fine-grained tokens, then Generate new token. GitHub now recommends fine-grained tokens over the older “classic” ones, since you can limit them to specific repos instead of your whole account.

Give it a Token name (anything memorable, like “claude-mcp”), and set an Expiration. GitHub warns against “no expiration” for good reason, pick 90 days and put a renewal reminder on your calendar.

Under Resource owner, pick your personal account (or the organization whose repos you need). Under Repository access, choose Only select repositories and pick just the ones Claude actually needs, not all of them.

Under Permissions, grant only what you’ll use. For most workflows, Contents (read and write) and Issues (read and write) cover it. Add Pull requests (read and write) if you want Claude opening or reviewing PRs.

Click Generate token at the bottom, then copy it immediately. GitHub shows a fine-grained token exactly once, if you navigate away before copying it, you’ll have to generate a new one.

That token (it starts with github_pat_) is what goes in place of “ghp_your_token_here” in the JSON config above:

"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your_actual_token"

brave-search follows the same pattern as github: one command, one args list to run the right package, and one env variable for its API key.

That’s the whole pattern. Every server you ever add to this file follows the same shape: a name you choose, a command to run it, arguments to configure it, and (if it needs to authenticate) an env block for its secrets.

Claude Code: Adding MCP Servers via CLI

Claude Code has its own MCP configuration surface separate from Claude Desktop, and it comes with a dedicated CLI command that makes setup faster than editing JSON manually.

You can install Claude Code following this guide: Claude Code Guide

Already have servers set up in Claude Desktop? Run claude mcp add-from-claude-desktop (macOS or WSL) to copy them straight into Claude Code instead of re-adding each one by hand.

Adding a Server with claude mcp add

The basic syntax is:

claude mcp add -- [args...]

That’s the pattern for a local server, one Claude Code runs itself as a subprocess. Hosted servers reached over a URL use –transport http instead and skip the — command entirely:

claude mcp add --transport http docs-server https://example.com/mcp

Hosted servers need no Node.js, no local process, and nothing to install. They’re the easiest first server to try. Local servers, like the Postgres example below, need a command Claude Code can actually run on your machine.

For a Postgres database server:

claude mcp add --transport stdio project-db \ -- npx -y @modelcontextprotocol/server-postgres \ postgresql://localhost:5432/mydb

Claude Code supports three scopes for server configuration:

Scope Config Location Who Sees It Best For

Local (default) ~/.claude.json (per-project) You only Personal tools, like GitHub, Slack, your DB

Project .mcp.json in project root Your whole team (committed) Shared servers like Linear, Sentry

User ~/.claude.json (top-level mcpServers key) Only you, all projects Personal tools you want everywhere, not project-specific

To verify setu

[truncated for AI cost control]