Configuration

This guide covers everything about configuring mcp servers.

Config file location

By default, mcp reads from:

~/.config/mcp/servers.json

Override with the MCP_CONFIG_PATH environment variable:

MCP_CONFIG_PATH=./my-servers.json mcp --list

If the file doesn't exist, mcp starts with zero servers. No error, no default file created — you build it as you go with mcp add or by editing the file directly.

File format

The config file is JSON with a single top-level key:

{
  "mcpServers": {
    "server-name": { ... },
    "another-server": { ... }
  }
}

Each server entry is identified by its name (the key). This name is what you use on the command line: mcp server-name --list.

Server types

Stdio servers

Stdio servers run as local processes. The CLI spawns them, communicates via stdin/stdout using JSON-RPC 2.0.

Field
Type
Required
Description

command

string

yes

The executable to run

args

string[]

no

Command-line arguments

env

object

no

Environment variables for the process

The command is the only required field. args defaults to [] and env defaults to {}.

HTTP servers

HTTP servers are remote endpoints. The CLI sends POST requests with JSON-RPC payloads.

Field
Type
Required
Description

url

string

yes

The server endpoint URL

headers

object

no

HTTP headers to include in every request

mcp handles both standard JSON responses and Server-Sent Events (SSE)arrow-up-right responses automatically. It also maintains session IDs when the server returns Mcp-Session-Id headers.

Environment variable substitution

Any value in the config can use ${VAR_NAME} to reference environment variables. They're resolved when the config is loaded.

If an env var is not set, it resolves to an empty string. This is intentional — it lets you have optional variables without breaking the config.

Works in any string value: env, headers, args, url, etc.

Server names

Server names are used as the first argument on the command line (mcp <name> ...). A few names are reserved and cannot be used:

  • search

  • add

  • remove

  • list

  • help

  • version

If you accidentally name a server with a reserved name, mcp will warn you at startup:

Adding servers

From the registry

This looks up the server in the MCP registryarrow-up-right, generates the config entry automatically, and tells you which env vars to set.

Manually (HTTP)

Manually (edit file)

Just open ~/.config/mcp/servers.json in your editor and add the entry.

Removing servers

This removes the entry from the config file.

Multiple configs

You can maintain different config files for different contexts:

Or use shell aliases:

Complete example

A real-world config with multiple server types:

Last updated

Was this helpful?