Skip to main content

MCP in Claude Code

TL;DR

  • Model Contact Protocol (MCP) is an open standard enabling AI agents like Claude Code to connect with external tools and data sources, significantly expanding the AI's contextual understanding.
  • MCP servers can be configured with varying scopes, including project-level configuration via an MCP.json file, to ensure consistent and automatic access to necessary tools for development teams.
  • While powerful, MCP tools can consume significant context window space even when idle, necessitating careful management and consideration of more context-efficient alternatives like CLI tools or "skills."

Takeaways

  • Understand MCP's Core Function: MCP allows Claude Code to integrate with external data sources and tools, such as databases, productivity apps, or public repositories, to enhance its ability to understand queries and perform tasks.
  • Add and Manage MCP Servers: Use the claude MCP add command to integrate new tools. Monitor server status and disable unused ones with the /mcp command within a Claude Code session to optimize context.
  • Choose Appropriate Server Types: Select HTTP servers for remote services hosted by providers or STDIO servers for local processes running on your machine.
  • Scope Servers for Team Collaboration: Implement project-scoped servers using an MCP.json file, checked into version control, to ensure that all team members automatically get the same configured tools.
  • Monitor Context Window Usage: Be aware that MCP servers add tool definitions to your context window even when not actively used; regularly disable inactive servers to prevent unnecessary context consumption.
  • Prioritize CLI for Efficiency: If a tool has a Command Line Interface (CLI) equivalent (e.g., gh for GitHub), using the CLI is more context-efficient as it avoids persistent tool definitions in the context window.
  • Utilize Skills for Dynamic Loading: Leverage "skills" which load their definitions into context only when Claude decides it needs them, providing a more context-efficient alternative to always-on MCP servers for certain tools.
  • Understand Automatic Tool Search Mode: Claude Code will automatically switch to tool search mode if MCP tools consume over 10% of the context window, attempting to discover tools on demand, though this may be less effective than having them already in context.

Vocabulary

  • Model Contact Protocol (MCP) — An open standard that enables AI agents, such as Claude Code, to connect to and interact with external tools and data sources.
  • Agentic AI — Artificial intelligence systems capable of performing actions, making decisions, and interacting with external environments or tools to achieve specific goals.
  • Context Window — The portion of an AI model's memory where current information, prompts, and tool definitions are held, directly influencing its processing and response generation.
  • HTTP Server — A type of MCP server used to connect Claude Code to remote services that are typically hosted by a service provider and accessed over a network.
  • STDIO Server — A type of MCP server designed to connect Claude Code to local processes that run directly on the user's machine.
  • MCP.json — A configuration file used for defining project-scoped MCP servers, allowing their settings to be version-controlled and shared automatically among team members.
  • CLI (Command Line Interface) — A text-based user interface used to interact with computer programs, often preferred for its context efficiency over MCP servers when an equivalent exists.
  • Skill — A named and described capability that an AI agent can dynamically load into its context window only when needed, offering a more context-efficient way to manage tool access.

Transcript

Model contact protocol is an open standard that lets Claude Code connect to external tools and data sources. When you ask a question, Claude will automatically understand when it should use those tools to better understand your query. Context is one of the most important parts when working with Claude Code. A lot of your context lives elsewhere like your databases, your productivity apps or in public repositories. This is where MCP comes in. First, it's important to understand the concept of tools when talking about agentic AI. Tools give agents like Claude Code the ability to perform actions in order for them to better complete their tasks. This is different from other AI where you just get an output back directly in text. Usually, for example, if your team is using linear as their project management software, you can add a linear MCP server to bring in the details of your specific issues. If you want to get up-to-date documentation of a dependency that you're working with, then the context 7 MCP server will provide Claude Code with that. There are also hundreds of different connectors at claude.com/connectors. You can add MCP servers with the claude MCP add command. There are two main types. HTTP servers are for remote services. These are hosted by the service provider and connect over the network. STDIO servers are for local processes that run on your machine. You can manage your servers with the /mcp inside a Claude Code session to see what's connected, the status, and disable servers that you don't want to use. MCP servers can be scoped in three different ways. One, local means it's only available in the current project for you. Two, the user, which means it's available across all your projects. And three, project scope uses a MCP.json file that you check into your version control. So, anyone working on the codebase gets the exact same servers automatically. Now, one thing to be aware of is that MCP servers add tool definitions to your context window, even when you're not using them. So, if you have a lot of servers configured, this eats into your available context. Run the /mcp command to see what's connected and disable anything that you're not actively using or don't think that you're going to use. If a tool has a CLI equivalent like gh for GitHub or AWS for AWS, the CLI is more context efficient because it doesn't add persistent tool definitions. You also might benefit from using a skill in this scenario. A skill has a name and a description that is loaded into context, similar to MCP. When Claw thinks it needs to use that skill, it then decides to load it into the context window, which is where you could put the command line interface tools. If your MCP tools exceed 10% of your context window, Claude Code will automatically switch to tool search mode, which will discover the right tools on demand. But this might not work as well since it's just not in the context. Now a quick recap. MCP connects Claude Code to your external tools and data sources. Add servers with Claude MCP ad. Scope them to your project with MCP JSON so that your team gets them automatically. And keep an eye out on the context usage by disabling servers that you're not actively using.

Feedback / ReportSpotted an issue or have an improvement idea?