All posts
AI Engineering·7 min read·Updated 18 Sept 2026

How to Use MCP in Claude Code (2026): Add, Scope, Authenticate and Remove Servers

Quick answer
To use MCP in Claude Code, add a remote server with claude mcp add --transport http <name> <url>, or a local one with claude mcp add <name> -- <command>. Choose --scope project to share it through .mcp.json, sign in to OAuth servers from /mcp, and check what is connected with claude mcp list.

A step-by-step guide to MCP in Claude Code: adding local and remote servers, local vs project vs user scope, OAuth login, environment variables, and removing servers.

Piyush Jangir
Verified author

Founder of StackPicks. Self-taught builder shipping open-source dev tools, marketing, and curator content since 2019. Based in Mumbai, India. Available on GitHub and LinkedIn.

7 min read
How to Use MCP in Claude Code (2026): Add, Scope, Authenticate and Remove Servers

**Short version:** one command adds a server, one flag decides who gets it, and one panel handles logins. Every command below is taken from Anthropic's Claude Code MCP documentation, checked in September 2026.

The four steps to using MCP in Claude Code

Step 1: Add the server

Remote servers are the easy case. Give the transport, a name and the URL:

claude mcp add --transport http notion https://mcp.notion.com/mcp

Local servers run a command on your machine. The double dash is required: Claude Code's options go before it, and everything after it is passed to the server untouched.

claude mcp add --env API_KEY=your-key --transport stdio myserver -- npx -y some-mcp-server

Step 2: Choose the scope

Claude Code MCP scopes: local, project and user

  • Local (default): only you, only this project. Stored in ~/.claude.json.
  • Project: everyone who clones the repo. Stored in .mcp.json at the repository root, so commit it.
  • User: only you, every project. Stored in ~/.claude.json.

Add --scope project or --scope user to the add command. Personal daily tools belong at user scope; team tools at project scope.

Step 3: Authenticate

Remote servers that use OAuth need a one-time login:

  1. Inside a session: run /mcp and follow the browser flow.
  2. From the terminal: run claude mcp login <name>.
  3. Over SSH: add --no-browser and open the printed URL on your own machine.
  4. To sign out: claude mcp logout <name>.

For servers that expect a static token, pass it as a header instead: --header "Authorization: Bearer your-token".

Step 4: Check, and prune

claude mcp list
claude mcp get <name>
claude mcp remove <name>

Prune regularly. Every connected server's tool definitions load into every request, which is a common reason people end up searching for how to reduce Claude Code token usage.

Which servers to start with

Start with three or four you will use weekly: GitHub, a documentation server such as Context7, and a browser server. Our shortlist of the best MCP servers for Claude Code has verified install commands for each, and the MCP directory lists 110.

Frequently asked questions

Where does Claude Code store MCP server configuration?+

It depends on scope. Local scope, the default, and user scope are both stored in ~/.claude.json: local servers load only in the current project, user servers in every project. Project scope writes the server to .mcp.json in the repository root, which you commit so everyone on the team gets the same servers when they clone the repo.

Why does my local MCP server fail to start in Claude Code?+

The most common cause is putting server arguments in the wrong place. Claude Code's own options, such as --transport, --env and --scope, must come before the double dash, and everything after it is passed to the server untouched. The next most common is a missing environment variable: pass it with --env KEY=value before the double dash, not as a shell variable.

How do I pass an API key to an MCP server in Claude Code?+

For a local server, use --env before the double dash, for example claude mcp add --env API_KEY=your-key --transport stdio myserver -- npx -y some-server. For a remote server that expects a header, use --header "Authorization: Bearer your-token". Prefer OAuth where the server supports it, because the token is then managed for you and never sits in a config file.

How do I log in to a remote MCP server from an SSH session?+

Run claude mcp login <name> --no-browser. It prints the authorisation URL instead of opening a browser on the remote machine, so you can complete the login from your own laptop. Inside an interactive session, the /mcp panel does the same job. To sign out and clear stored credentials, run claude mcp logout <name>.

Can I share MCP servers with my team in Claude Code?+

Yes, with project scope. claude mcp add --scope project writes the server to .mcp.json at the repository root, and anyone who clones the repository gets it. Each person still authenticates with their own account for OAuth servers, so shared configuration never means shared credentials. Keep secrets out of .mcp.json and let each developer supply their own.

More in AI Engineering

How to Use MCP in Claude Code (2026): Add, Scope, Authenticate and Remove Servers — StackPicks — StackPicks