Home AI SkillsHow to Connect Claude Code to MCP Servers: A Practical Guide

How to Connect Claude Code to MCP Servers: A Practical Guide

by Knowledge Base Linux
How to Connect Claude Code to — How to Connect Claude Code to MCP Servers: A Practical Guide

Out of the box, Claude Code can read files, edit code and run shell commands. Claude Code MCP servers remove that ceiling. MCP — the Model Context Protocol — is an open standard that lets external programs expose tools, data and prompts to AI agents in a uniform way. Connect a server and Claude gains new abilities: querying your issue tracker, reading a database, driving a browser, searching internal documentation, or calling your company’s own internal tools — all from the same terminal session. (In our earlier guide we built an MCP server for infrastructure queries; this article is the other side of the wire — connecting Claude Code as the client.)

Add Your First of Many Claude Code MCP Servers – How to Connect Claude Code to

Local MCP servers run as child processes that Claude Code starts for you. Everything after the -- in the add command is the command used to launch the server:

# Filesystem access scoped to one directory tree
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/projects

# List what is configured and its connection status
claude mcp list

Secrets belong in environment variables, never in arguments that end up in shell history and process listings:

claude mcp add --env API_KEY=your-secret-key myserver -- npx -y my-mcp-server

Remote servers are just as easy. Modern servers use the HTTP transport; older SSE servers still work but are deprecated:

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

Remote servers usually authenticate with OAuth: start a session, type /mcp, choose the server and finish the sign-in in your browser. If a service issues a fixed token instead, pass it as a header with --header "Authorization: Bearer ...".

Scopes: Who Gets Which Servers – How to Connect Claude Code to

Every server is registered at one of three scopes, chosen with --scope:

Scope Stored in Who sees it
Local (default) ~/.claude.json, under this project Only you, only in this project
Project .mcp.json in the project root Everyone who clones the repository
User ~/.claude.json, top level Only you, in every project

The working rule: project scope for servers the whole team needs for that repo (commit the .mcp.json file — but never commit real secrets into it; reference environment variables instead), user scope for your personal toolkit, local scope for experiments. When someone clones a project with shared servers, Claude Code asks them to approve the project servers before connecting, which is an important safety checkpoint.

Claude Code MCP servers bridging the agent to databases and APIs

Managing Claude Code MCP Servers Day to Day

claude mcp list              # all servers + status
claude mcp get filesystem    # details for one server
claude mcp remove filesystem # unregister a server

Inside a session, /mcp shows live connection status, lets you reconnect a dropped server, and handles OAuth flows. Once connected, a server’s tools appear alongside the built-in ones, and you can refer to exposed resources directly in conversation with an @ mention — for example asking Claude to compare a spec stored in a connected tool against the implementation in your repo. For scripted or CI use, the --mcp-config flag loads servers from a JSON file for that run only, without touching your saved configuration.

What Should You Connect First?

  • Issue tracker / project tools (GitHub, Linear, Jira): triage, context and status updates without leaving the terminal.
  • Documentation servers: up-to-date library docs so the agent stops guessing APIs — a genuine accuracy upgrade.
  • Database servers (read-only!): schema exploration and safe querying during debugging.
  • Browser automation: reproduce front-end bugs and verify fixes visually.
  • Your own internal tools: if your team can write a small script, it can wrap it as an MCP server — this is where MCP stops being a novelty and becomes infrastructure.

Troubleshooting a Server That Won’t Connect

When a server shows as failed, work through three checks before changing anything. First, run the server’s launch command yourself in a plain terminal — most “MCP problems” are really a missing npx package, a wrong path, or an unset environment variable that the manual run exposes immediately. Second, open /mcp in a session and read the actual connection error rather than guessing; for remote servers, an incomplete OAuth flow is the usual culprit, and the same menu lets you finish it. Third, confirm the scope you intended: a server added at local scope will not appear in your other projects, and a project-scope server requires approval from each teammate before it connects on their machine.

Security Rules for Claude Code MCP Servers

An MCP server is code that runs with your permissions and feeds content into your agent’s context. Treat it accordingly:

  • Install servers only from sources you trust, and pin versions where you can.
  • Review any .mcp.json that arrives with a cloned repository before approving it.
  • Give database and cloud servers read-only credentials by default.
  • Remember that tool output can contain injected instructions; keep hooks and permission rules as your guardrails for sensitive actions.

Anthropic’s official MCP documentation covers transports, configuration formats and troubleshooting in depth. Start with one high-value server — your issue tracker or your docs — and within a week the terminal will feel strangely incomplete without it.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.