MCP Servers in Claude Code: Connecting and Configuring
Why an agent needs MCP servers, how to connect one to Claude Code, how to verify it is actually visible, and the errors people hit most often when wiring them up.
All articles in the guide Claude Code · 13
MCP is how you give the agent tools it does not have out of the box. Out of the box it works with files and runs commands; everything else - databases, trackers, external services - arrives through servers.
Why an agent needs MCP
The problem is simple: the agent answers from what it can see. If the data lives outside the repository, it does not know about it and starts guessing.
The cases where a server earns its place:
- A database. The agent sees the real schema rather than your paraphrase, and writes queries against it.
- An issue tracker. It can read the ticket instead of you pasting it into chat.
- An external API. Reaching a service that holds data the task needs.
- Documentation and internal knowledge bases, especially where decisions cannot be derived from the code.
The flip side: every connected server adds tool descriptions to context. Ten servers “just in case” is a measurable cost in every task, including the ones where none of them are needed. Connect what you use. Context spend is covered in limits.
Connecting a server
The order is nearly the same for every server:
- Work out what kind it is. A local program the agent launches, or a remote service it connects to. That decides the shape of the configuration.
- Add it to the configuration - a launch command or an address, plus environment variables holding credentials.
- Put secrets in the environment, not in a config file inside the repository. Exactly the same story as the API key.
- Choose the scope. A server can be personal, available across all your projects, or project-scoped, in which case the whole team picks it up.
- Restart the agent. Configuration is read at startup.
A note on project-scoped servers: if the server is described in the repository, everyone who opens the project gets it. That is convenient, and it also means somebody else’s repository can bring along a server configuration you have not read. Look at what you are connecting.
Verifying it is visible
Three checks, in increasing order of reliability:
- The server list in the interface, which shows status: running, failed, not found.
- The tool list. Ask the agent which tools it has. A server can be running and still expose nothing if it failed to authenticate.
- A real call. Ask for something small and safe through that server. Only this confirms the whole chain works.
Common errors
- The server does not start. Usually the launch command is not found: the agent starts it in its own environment rather than your shell, and
PATHmay differ. Use a full path when in doubt. - It starts but exposes no tools. Authentication failed. Check the environment variables: an empty variable looks exactly like a missing one.
- Tools exist but the agent ignores them. The descriptions are too vague for it to know when they apply. That is fixed on the server side, in the descriptions.
- Everything works, slowly. The server calls an external system on every invocation. Sometimes exporting the data to a file once is cheaper.
- Name collisions. Two servers expose similarly named tools and the agent picks the wrong one. Disconnect the one you do not need.
Next
On the protocol itself and how to write your own server, see the MCP guide. MCP pairs well with skills: the skill describes the procedure, the server provides the data it needs. The overview is in the Claude Code guide.
FAQ
What is an MCP server in plain terms?
It is a broker program that gives the agent access to something beyond the project files: a database, an issue tracker, an external API. The agent sees it as a set of described tools and calls them when a task needs data the repository does not contain.
How do I check that an MCP server connected?
The interface lists connected servers and their status. A server that is listed but marked as failed has a startup problem, not a config problem. The second check is asking the agent which tools it has: it will list what it actually sees.
Is it safe to give an agent database access through MCP?
Exactly as safe as the permissions you granted. The agent will do what it can, including modifying data if that right exists. In practice: a dedicated database user, read-only by default, and no production until the workflow has been proven.
- Claude Code: A Complete Practical GuideGuide
- Claude Code in Russia: Access, Payment and LimitsWhat actually fails when using Claude Code from Russia, which payment routes remain, how to tell an access problem from a configuration error, and what the service rules mean for your account.
- Claude Code API Key: Where to Get One and How to Connect ItWhere the Claude Code API key is created, where to store it, how your own key differs from a subscription in cost and predictability, and what to do about a 401.
- Claude Code CLI: Commands, Flags and ModesHow Claude Code starts, what the permission modes actually mean, which flags earn their keep in daily work, and what belongs in project configuration instead of being retyped.
Done for you
Need the result, not the agent setup? I will build your MVP
I work in Claude Code every day and take products all the way to users.
from $1,500 · 1 to 2 weeks