Skip to main content

Configuring MCP Servers

Module: MCP Servers | Lesson: 2 of 4 | Time: ~10 minutes

What You Will Learn

  • How to configure MCP servers in settings.json
  • How to use claude mcp add to add servers
  • How to run servers with npx

Prerequisites

Two Ways to Configure MCP Servers

There are two ways to add an MCP server to Claude Code:

  1. The claude mcp add command — quick and easy, done from the terminal
  2. Editing .claude/settings.json manually — gives you full control over the configuration

Both methods achieve the same result. The CLI command is faster for simple setups, while editing the settings file directly is better when you need to customize options.

Method 1: Using claude mcp add

The quickest way to add an MCP server is from your terminal:

claude mcp add <name> -- <command> [args...]

For example, to add the Filesystem MCP server:

claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem C:\Users\YourName\Documents

Let us break this command down:

PartMeaning
claude mcp addThe command to add a new MCP server
filesystemThe name you give this server (you choose this)
--Separator between the name and the server command
npx -y @modelcontextprotocol/server-filesystemThe command to start the server
C:\Users\YourName\DocumentsArguments passed to the server (in this case, the folder to access)

After running this, Claude Code will save the configuration and the server will be available next time you start a session.

Managing MCP Servers from the CLI

You can also list and remove servers:

# List all configured MCP servers
claude mcp list

# Remove a server
claude mcp remove filesystem

Method 2: Editing settings.json

MCP servers are stored in your Claude Code settings file. The location depends on whether you want the server available globally or just in one project:

ScopeFile Location
Global (all projects)~/.claude/settings.json
Project (this project only).claude/settings.json in your project root

Open the settings file and add an mcpServers section:

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

Anatomy of an MCP Server Configuration

Each server entry has a name (the key) and a configuration object:

{
"mcpServers": {
"server-name": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-package"],
"env": {
"API_KEY": "your-api-key-here"
}
}
}
}
FieldRequiredDescription
commandYesThe program to run (usually npx, node, or python)
argsYesArguments passed to the command
envNoEnvironment variables the server needs (like API keys)
Protect Your API Keys

If a server needs an API key, do not commit the settings file to Git with the key in plain text. Use environment variables or a .env file and reference them in your configuration. Add .claude/settings.json to your .gitignore if it contains secrets.

Local vs Remote Servers

Most MCP servers run locally on your machine using the stdio transport (standard input/output). This is the default and most common setup.

Some servers support remote connections over HTTP using the SSE (Server-Sent Events) transport:

{
"mcpServers": {
"remote-server": {
"url": "https://mcp.example.com/sse"
}
}
}

For remote servers, you use url instead of command and args.

note

As a beginner, you will almost always use local stdio servers. Remote servers are an advanced option typically used in team or enterprise setups.

Configuration Examples

GitHub MCP Server

{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
}
}
}
}

Brave Search MCP Server

{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-brave-search"],
"env": {
"BRAVE_API_KEY": "your_brave_api_key"
}
}
}
}

Multiple Servers Together

You can configure as many servers as you need:

{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "C:\\Projects"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
}
}
}
}

Try It Yourself

Add the Filesystem MCP server using the CLI command:

  1. Pick a folder on your machine that you want Claude to be able to access (for example, your Documents folder)
  2. Run the add command:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem C:\Users\YourName\Documents
  1. Verify it was added:
claude mcp list
  1. Start Claude Code and type /mcp to confirm the server is connected
  2. Ask Claude: "What files are in my Documents folder?" and watch it use the Filesystem server to answer
Windows Paths

When specifying Windows paths in the CLI command, use them as-is: C:\Users\YourName\Documents. When writing them in JSON, you need to escape the backslashes: C:\\Users\\YourName\\Documents. Alternatively, use forward slashes which work in both: C:/Users/YourName/Documents.

What You Learned

  • Use claude mcp add for quick server setup from the terminal
  • Edit .claude/settings.json for full control over server configuration
  • Each server config needs a command and args at minimum
  • Environment variables (env) pass secrets like API keys to servers
  • Local servers use stdio (most common), remote servers use a URL
  • You can configure multiple servers — they all appear in Claude's toolbox

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Popular MCP Servers