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 addto add servers - How to run servers with npx
Prerequisites
- Completed What Are MCP Servers?
Two Ways to Configure MCP Servers
There are two ways to add an MCP server to Claude Code:
- The
claude mcp addcommand — quick and easy, done from the terminal - Editing
.claude/settings.jsonmanually — 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:
| Part | Meaning |
|---|---|
claude mcp add | The command to add a new MCP server |
filesystem | The name you give this server (you choose this) |
-- | Separator between the name and the server command |
npx -y @modelcontextprotocol/server-filesystem | The command to start the server |
C:\Users\YourName\Documents | Arguments 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.
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:
| Scope | File 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"
}
}
}
}
| Field | Required | Description |
|---|---|---|
command | Yes | The program to run (usually npx, node, or python) |
args | Yes | Arguments passed to the command |
env | No | Environment variables the server needs (like 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.
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:
- Pick a folder on your machine that you want Claude to be able to access (for example, your Documents folder)
- Run the add command:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem C:\Users\YourName\Documents
- Verify it was added:
claude mcp list
- Start Claude Code and type
/mcpto confirm the server is connected - Ask Claude: "What files are in my Documents folder?" and watch it use the Filesystem server to answer
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 addfor quick server setup from the terminal - Edit
.claude/settings.jsonfor 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
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.