Skip to content
mentoor

Topic 1 of 5 · 4 min read

Configuring local and remote MCP servers

Goal: Add a local and a remote MCP server at the right scope with credentials kept out of the committed config.

Add each MCP server at the narrowest scope that works, and never let a secret land in a file that is committed. An MCP server is a program that offers tools (query a database, open a ticket, read a design file) to your coding agent. Connecting one is a config change with real consequences, so treat it like adding a dependency.

Check yourself · 1 of 3

A teammate and you both need the same hosted MCP server, and it needs an API key. Where should the key live?

Choose one answer

Why it matters

A server added at the wrong scope leaks to every teammate or every project. A token pasted into a shared config leaks to everyone who can read the repo. Both mistakes are common because the quick path in a tutorial often does exactly that.

Two kinds of server

  • Local (stdio). The agent starts a process on your machine and talks to it through standard input and output. Good for tools that touch local files or need your credentials. You supply the command to run.
  • Remote (HTTP). The server runs elsewhere, and the agent calls a URL. Good for hosted services. Sign-in is usually OAuth: the agent opens a browser, you approve, and a token is stored for you. In Claude Code you trigger it from the /mcp menu.

Three scopes

In Claude Code, local is just you in this project, project is written to a shared .mcp.json that is committed, and user is you in every project. Other agents use different file names, but the same three-way split.

How to do it

  1. Decide who needs the server. Only you? Use local or user. The whole team? Use project.
  2. Add it with the CLI so the file is written correctly.
  3. Put secrets in environment variables, and reference the variable in the config, not the value.
  4. Check it connects, then try one harmless tool call.
# Remote server, shared with the team (OAuth, no secret in the file)
claude mcp add --transport http --scope project issues https://mcp.example.com/mcp

# Local server, private to you
claude mcp add --transport stdio --scope local db \
  --env DB_URL="$DB_URL" -- npx -y @example/db-mcp

Before and after

Weak: a project .mcp.json with the token written in.

{ "mcpServers": { "issues": { "type": "http", "url": "https://mcp.example.com/mcp",
  "headers": { "Authorization": "Bearer sk_live_...redacted" } } } }

Fixed: the file holds a reference, and each developer sets the variable in their own shell.

{ "mcpServers": { "issues": { "type": "http", "url": "https://mcp.example.com/mcp",
  "headers": { "Authorization": "Bearer ${ISSUES_TOKEN}" } } } }

What goes wrong

  • A secret is committed, then removed in a later commit. It stays in history and must be rotated.
  • A personal server is added at project scope, so every teammate is prompted to run something they never chose.
  • A local server uses npx with no pinned version, so what runs changes without notice.

Examples

Project server with a variable reference

The team shares a docs-search server. The committed .mcp.json points at its URL and uses ${DOCS_KEY} in the header. The README tells each developer to export DOCS_KEY from their password manager. A new teammate clones, exports the variable and the server works. The key never touches git.

Personal server at user scope

You run a local notes server for your own use. You add it with --scope user so it follows you across projects, and it never appears in any repo or in a teammate's prompt.

Key points

  • Local stdio servers run as a process on your machine; remote HTTP servers are called by URL and usually sign in with OAuth.
  • Scope decides who gets the server: only you in one project, you everywhere, or everyone who clones the repo.
  • A committed config may reference an environment variable but must never contain the secret value.
  • Add servers with the CLI so the config file is written in the right shape and place.
  • After adding a server, confirm it connects and make one harmless call before relying on it.

Common mistakes

  • Pasting a token into a committed config because it worked on the first try.
  • Choosing project scope for a server only you need.
  • Leaving the package version unpinned for a local server started by a package runner.
  • Assuming OAuth tokens last forever, then being surprised when sign-in is needed again.

Check yourself · 2 of 3

Which scope makes an MCP server available to everyone who clones the repository?

Choose one answer

Check yourself · 3 of 3

What is the main difference between a local stdio server and a remote HTTP server?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic