DEV Community

Cover image for Claude Code MCP: how to add an MCP server (local or remote)
Philipp Shayzhanov
Philipp Shayzhanov

Posted on Originally published at vbtnl.com AI-assisted

Claude Code MCP: how to add an MCP server (local or remote)

Claude Code MCP servers give Claude Code new tools. For example, a GitHub server lets it read issues, a Playwright server lets it open a browser, and a hosting server lets it put your app online.

You add a server with one command:

claude mcp add --transport http my-server https://example.com/mcp
Enter fullscreen mode Exit fullscreen mode

That's the short version. Below is the rest: local and remote servers, where the settings are saved, how to log in, and what to do when a server doesn't connect.

Local or remote?

There are two kinds of MCP servers.

  • Local (stdio). The server is a program on your computer. Claude Code starts it for you, usually with npx or uvx.
  • Remote (HTTP). The server runs somewhere on the internet. Claude Code connects to its address. Nothing to install.

The README of the server tells you which kind it is. If it gives you a URL, it's remote. If it gives you a command like npx something, it's local.

Add a remote MCP server

Use --transport http, a name you choose, and the server's URL:

claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
Enter fullscreen mode Exit fullscreen mode

Most remote servers need you to log in. There are two ways.

Log in with the browser (OAuth). Open Claude Code, type /mcp, pick the server and choose Authenticate. A browser page opens, you log in and allow access. You can also do it from the terminal:

claude mcp login sentry
Enter fullscreen mode Exit fullscreen mode

Use a token. Some servers give you an API key instead. Send it in a header:

claude mcp add --transport http my-server https://example.com/mcp \
  --header "Authorization: Bearer YOUR_TOKEN"
Enter fullscreen mode Exit fullscreen mode

Add a local MCP server

Put -- before the command that starts the server. Everything after -- is the command:

claude mcp add playwright -- npx @playwright/mcp@latest
Enter fullscreen mode Exit fullscreen mode

If the server needs an API key, pass it with -e:

claude mcp add my-server -e API_KEY=YOUR_KEY -- npx my-mcp-server
Enter fullscreen mode Exit fullscreen mode

You need Node.js for npx servers and Python with uv for uvx servers.

Where the server is saved: scopes

By default a server works only in the folder where you added it. Use --scope to change that:

Scope Where it works Where it's saved
local (default) Only in this folder, only for you Your Claude Code settings
user In every folder on your computer Your Claude Code settings
project For everyone who works on this repository .mcp.json in the project root

Want a server everywhere? Add --scope user:

claude mcp add --scope user --transport http sentry https://mcp.sentry.dev/mcp
Enter fullscreen mode Exit fullscreen mode

Share servers with your team: .mcp.json

With --scope project, Claude Code writes the server into .mcp.json. You commit this file, and your team gets the same servers. It looks like this:

{
  "mcpServers": {
    "my-server": {
      "type": "http",
      "url": "https://example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${MY_SERVER_TOKEN}"
      }
    },
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": ["@playwright/mcp@latest"],
      "env": {}
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Don't put real tokens in this file, because it goes to git. Write ${MY_SERVER_TOKEN} instead, and each person sets the variable in their own terminal. Claude Code puts the value in when it connects.

The first time someone opens the project, Claude Code asks them to approve the servers from .mcp.json. That's normal: a file from git shouldn't run programs on your computer without asking.

Check that it works

In the terminal:

claude mcp list
Enter fullscreen mode Exit fullscreen mode

You see every server and whether it is connected. For one server:

claude mcp get sentry
Enter fullscreen mode Exit fullscreen mode

Inside Claude Code, type /mcp. It shows the same list, and you can log in, reconnect or turn a server off there.

Then just ask Claude to use it: "List my open Sentry issues". If the server works, Claude calls its tools.

Remove a server

claude mcp remove sentry
Enter fullscreen mode Exit fullscreen mode

Claude Code finds it in any scope. If you have servers with the same name in two scopes, say which one: claude mcp remove --scope user sentry.

When the server doesn't connect

  • "Failed to connect" for a remote server. Check the URL. Many servers end with /mcp. Open /mcp in Claude Code and try Authenticate again.
  • "Needs authentication". You haven't logged in yet, or the login expired. Run /mcp or claude mcp login <name>.
  • 401 or 403 with a token. The header must be exactly Authorization: Bearer <token>, with one space after Bearer. Check that the token is not expired.
  • A local server fails to start. Run its command by hand in the terminal, for example npx @playwright/mcp@latest. You will see the real error, often a missing Node.js or Python.
  • The server is connected, but Claude doesn't use it. Name it in your request: "use the Playwright MCP to open the page". Claude picks tools by their names and descriptions.
  • A server from .mcp.json is "pending approval". Approve it in /mcp. If you said no by mistake, run claude mcp reset-project-choices.

Example: a remote server that deploys your code

Here is a real remote MCP server: vbtnl. It gives Claude Code tools to create a project on a server, write files there, run them and publish the app to a public address.

claude mcp add --scope user --transport http vbtnl https://api.vbtnl.com/mcp
Enter fullscreen mode Exit fullscreen mode

Then /mcp, pick vbtnl and log in. Now you can ask:

Make a landing page with a waitlist and put it online on vbtnl.
Enter fullscreen mode Exit fullscreen mode

Claude writes the code on the server, starts it and replies with a link. For a full example, see Deploy a Telegram bot for free with Claude Code. Setup for other apps is in the docs.

Which MCP servers to add

Start with the ones that match your daily work. Popular choices for Claude Code:

  • GitHub for issues and pull requests.
  • Playwright to open pages in a real browser and test them.
  • Figma to read designs and turn them into code.
  • A database server (Postgres, Supabase) to look at your data.
  • A hosting server like vbtnl to put what Claude builds online.

Don't add twenty servers at once. Every server adds tools, and with too many tools Claude picks the wrong one more often. Add what you use, remove what you don't.

Questions

What is the difference between Claude Code and Claude Desktop for MCP?

Claude Code adds servers with claude mcp add or .mcp.json. Claude Desktop and claude.ai add remote servers as custom connectors in Settings. On a Mac you can copy servers from Claude Desktop with claude mcp add-from-claude-desktop.

Can I add a server from a JSON config?

Yes. claude mcp add-json my-server '{"type":"http","url":"https://example.com/mcp"}' takes the same JSON as .mcp.json.

Do MCP servers see my code?

A server sees only what Claude sends to it in a tool call. Still, a local server is a program on your computer, so add only servers you trust.

Does the same work in Codex?

Almost. Codex has its own command: codex mcp add. See Connect Codex.

More answers are in the FAQ.

Give Claude Code a place to ship. Add vbtnl as a remote MCP server and get a live link for what Claude builds. Start at vbtnl.com.

Originally published on the vbtnl blog.

Top comments (8)

Collapse
 
osaka_dx_engineer profile image
Osaka_WebDeveloper •

The scope table was the most useful part for me — I had been adding everything locally and wondering why teammates didn't get the same servers, so the distinction between local, user and project scope finally makes it click. I also appreciated the warning not to commit real tokens to .mcp.json and to use ${MY_SERVER_TOKEN} instead, since that's an easy mistake in a shared repo. The troubleshooting note about naming the server explicitly when Claude is connected but doesn't use it matches what I've seen with Playwright, where a direct instruction makes a big difference. One thing I'd add from experience is that checking with claude mcp list right after adding a server saves a lot of guessing later.

Collapse
 
kinzarra profile image
Philipp Shayzhanov •

Thanks, glad the scope table helped. That local vs project mix-up is the most common one I see too. Good point about running claude mcp list right away. One more check that saves time: claude mcp get shows which scope the server was saved in. That would have shown your "local" servers at once. For the team setup, one thing to tell your teammates: the first time they open the project, Claude Code asks them to approve the servers from .mcp.json. If someone says no by mistake, claude mcp reset-project-choices brings the question back.

Collapse
 
osaka_dx_engineer profile image
Osaka_WebDeveloper •

Thanks — claude mcp get is a good addition. It shows the resolved config instead of what I think I wrote, which is where most of my setup mistakes hide. I'll run both checks right after adding a server from now on.

Thread Thread
 
kinzarra profile image
Philipp Shayzhanov •

"What I think I wrote" is the right way to put it, most of my own MCP bugs were exactly that. One more for the routine: /mcp inside a session shows what actually connected and which tools the server exposed, not just what is in the config. Handy for remote servers that are still waiting for login.

Thread Thread
 
osaka_dx_engineer profile image
Osaka_WebDeveloper •

Good point — /mcp shows the live state, not just the config. That's the check that catches a remote server still waiting on login. Adding it to the routine, thanks.

Collapse
 
mona_d_4222dda374567263b profile image
Amber D. •

This is one of the clearest MCP setup guides I've come across. It does what good tutorials rarely do: it gives you the one-line answer first, then lets you go deeper only if you need to.

A few things stood out.

The local versus remote framing. Opening with "if the README gives you a URL, it's remote; if it gives you npx something, it's local" is a small heuristic that removes the most common point of confusion. Many people stall right there because the docs assume you already know the difference.

The scopes table. Local, user and project scope are easy to mix up, and a three-row table showing where each one works and where it's saved is far more useful than a paragraph of explanation. The default being "only this folder, only for you" is worth knowing before you wonder why a server vanished in another directory.

The .mcp.json guidance. The advice to use ${MY_SERVER_TOKEN} instead of a real token is exactly the kind of detail that prevents an accidental credential leak into git. I also liked that you explain the approval prompt rather than just mentioning it: a file pulled from a repository shouldn't be able to launch programs on your machine without asking. That reasoning makes the behavior feel like a feature rather than an annoyance.

The troubleshooting section. It's organized by the symptom a person would actually see, and the fixes are concrete. The tip to run a failing local server's command by hand to see the real error is the one I'd flag as most valuable, since the cause is so often a missing Node.js or Python install that the connection message never reveals. The note about the single space after Bearer is the sort of thing that costs people an hour.

Don't add twenty servers. This is the most underrated advice in the piece. Every server adds tool definitions, and a crowded tool list makes wrong tool choices more likely. A short rule like "add what you use, remove what you don't" is easy to remember and saves real frustration.

One small suggestion: a line on checking what a remote server can actually do before authenticating, such as reviewing its tool list in /mnt or the server's docs, might help readers think about permissions as well as connection. You touch on trust in the FAQ, and a bit more there would be a natural extension.

Thanks for writing something so practical and well organized.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

clear walkthrough. remote MCP auth is the fiddly part, local is straightforward.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

Every MCP server's tool list goes into the context each time the model is called, so an unused server is a standing cost. Add only the servers a task needs.