Getting Started with Claude Code MCP: Connecting External Tools and Context Management Practices

MCP is an open standard connecting Claude Code to external tools, requiring careful context management.
MCP (Model Context Protocol) is an open standard released by Anthropic, inspired by LSP's design philosophy, establishing a unified communication protocol between AI models and external tools. It supports both HTTP and STDIO transport methods and offers three scopes: local, user, and project. When using MCP, be aware that tool definitions consume context window space. Best practices include preferring CLI alternatives, leveraging Skills for on-demand loading, and regularly cleaning up inactive servers.
What is MCP?
Model Context Protocol (MCP) is an open standard that enables Claude Code to connect to external tools and data sources. When you ask questions, Claude automatically determines when to use these tools to better understand your needs.
MCP was officially released by Anthropic in late 2024, with its design inspired by the Language Server Protocol (LSP)—a standardized protocol widely used in the IDE ecosystem. LSP solved the M×N integration problem between editors and programming languages, simplifying it to M+N linear complexity. For example, before LSP, supporting 10 languages across 10 editors required 100 integration adapters; with LSP, only 10+10=20 implementations are needed. MCP adopts the same approach, establishing a unified communication standard between AI models and external tools, eliminating the need for every AI application to write custom integration code for each data source. This means tool developers only need to implement the MCP protocol once to make their service available to all MCP-compatible AI clients.

When using Claude Code, context is one of the most critical elements. However, vast amounts of contextual information are scattered across various locations—your databases, productivity applications, or public code repositories. MCP was created to solve exactly this problem.
Understanding the Concept of "Tools"
When discussing AI Agents, you first need to understand the concept of "Tools." Tools give Agents like Claude Code the ability to perform concrete actions, enabling them to better accomplish tasks. This is fundamentally different from traditional AI that simply returns output as text—Agents can proactively invoke tools to retrieve information and execute operations.
From a technical perspective, tool calling (Function Calling/Tool Use) is one of the core capabilities of modern large language models. Here's how it works: when generating a response, the model can output not only text but also structured tool call requests (typically in JSON format, containing the tool name and parameters). The system intercepts this request, executes the corresponding tool function, and returns the execution result to the model. The model then continues reasoning based on the tool's returned results, ultimately generating a response for the user. This "think-act-observe" loop mechanism (also known as the ReAct pattern) transforms AI from a passive text generator into an intelligent Agent capable of proactively acquiring information and executing operations. Within the MCP framework, the definitions and calling interfaces of these tools are standardized, ensuring that tool discovery, description, and invocation all follow a unified protocol specification.
Practical Use Cases
- Project Management Integration: If your team uses Linear as a project management tool, you can add a Linear MCP server to bring specific Issue details into Claude Code's context
- Real-time Documentation Queries: If you need the latest documentation for a dependency library, the Context7 MCP server can provide this information to Claude Code
- More Connectors: Hundreds of different connectors are available at claude.ai/connectors
How to Add and Manage MCP Servers
Adding Servers
Use the claude mcp add command to add MCP servers. Servers come in two main types:
- HTTP Servers: For remote services, hosted by service providers and connected over the network
- STDIO Servers: For local processes, running directly on your machine
The technical differences between these two transport methods are worth understanding in depth. STDIO (Standard Input/Output) is a fundamental method of inter-process communication in Unix systems. MCP's STDIO transport mode communicates by launching a subprocess and exchanging JSON-RPC messages through standard input/output streams. When you add a STDIO-type MCP server, Claude Code actually starts a local process (typically a Node.js or Python script) and communicates with it via stdin/stdout. This approach has extremely low latency (typically in milliseconds) but is limited to local use. HTTP transport mode (based on Server-Sent Events/SSE or the latest Streamable HTTP) allows clients to connect to remote servers over the network, suitable for cloud-hosted services, but introduces network latency and authentication complexity. Which type to choose depends on your use case: local database queries are suited for STDIO, while connecting to SaaS services typically uses HTTP.
Managing Servers
Use the /mcp command within a Claude Code session to:
- View connected servers
- Check connection status
- View related data
- Disable servers you don't need
Three Scopes for MCP Servers
MCP servers can operate within three different scopes:
- Local: Available only to you in the current project
- User: Available across all your projects
- Project: Uses a
.mcp.jsonfile committed to version control, so anyone working on the codebase automatically gets the exact same server configuration
The project-level scope is particularly well-suited for team collaboration, ensuring all members have a consistent development environment. The .mcp.json file's design philosophy is similar to .vscode/settings.json or .editorconfig and other project-level configuration files—by committing the configuration file to the Git repository, it achieves environment consistency across team members. This Infrastructure as Code approach ensures that new members get a complete toolchain configuration immediately after cloning the repository, without manual setup, significantly reducing friction in team collaboration. Note that for security reasons, configurations containing sensitive information like API keys should not be written directly into .mcp.json, but should instead be referenced through environment variables.
Context Management: Key Considerations
Context Window Consumption
MCP servers add tool definitions to your context window, even when you're not actively using those tools. If you have many servers configured, this can significantly erode your available context space.
To understand the severity of this issue, you need to understand the technical limitations of the context window. The context window refers to the maximum number of tokens a model can process in a single inference. Even though modern models like Claude support 200K token context windows, in real-world coding scenarios, code files, conversation history, system prompts, and other content quickly consume available space. Tool definitions describe each tool's name, parameter types, functionality, and usage examples in JSON Schema format, with each tool potentially consuming hundreds to thousands of tokens. If an MCP server exposes 20 tools, with each tool definition averaging 500 tokens, that single server alone occupies 10,000 tokens of context space—and that's not counting the return results from tool calls. When you connect multiple MCP servers simultaneously, the cumulative consumption of tool definitions can reach tens of thousands of tokens, severely compressing the space available for actual code and conversation.
Recommendation: Regularly run the /mcp command to check connected servers and disable those that aren't actively used or aren't expected to be needed.
CLI Alternatives Are More Efficient
If a tool has a CLI equivalent (such as GitHub's gh command or AWS's aws command), using the CLI is more context-efficient because it doesn't add persistent tool definitions. When Claude Code executes CLI commands through the Bash tool, it only needs to know the command syntax (which is typically already included in the model's training knowledge), rather than maintaining a complete tool Schema definition in the context. Command output is also one-time and doesn't persistently occupy context space like MCP tool definitions do.
Using Skills to Optimize Context
In this scenario, you can also consider using Skills. Skills have names and descriptions that are loaded into the context. Similar to MCP, when Claude determines it needs a particular Skill, it decides to load it into the context window—you can place CLI tool invocation patterns within them. Skills are essentially Markdown files stored in the project's .claude/ directory, and they are more lightweight than full MCP tool definitions. You can encapsulate commonly used CLI command patterns, API call templates, or workflows as Skills, achieving a "load on demand" rather than "always occupying" context management strategy.
Automatic Tool Search Mode
When MCP tools occupy more than 10% of the context window, Claude Code automatically switches to Tool Search Mode, discovering appropriate tools on demand. In this mode, Claude doesn't load all tool definitions into the context. Instead, it first searches for potentially relevant tools based on the semantic description of the current task, then only loads the tool definitions with the highest match scores. This is similar to how a search engine works—search first, then read in detail. However, note that this mode may not be as precise as directly loading tool definitions into the context, because the search process itself might miss certain tools that are useful in specific scenarios but whose descriptions don't match well enough.
Best Practices Summary
- Add on Demand: Use
claude mcp addto add only the servers you truly need - Team Sharing: Commit configurations to version control via
.mcp.jsonfiles to ensure team consistency - Monitor Context: Regularly check and disable inactive servers to maintain efficient context window utilization
- Prefer CLI: For services with command-line tools, prefer CLI over MCP connections
- Leverage Skills: Encapsulate commonly used CLI tools as Skills for on-demand loading
MCP opens the door for Claude Code to connect with the external world, but managing context resources wisely is equally important. Mastering this balance is what allows AI Agents to truly achieve maximum effectiveness.
Related articles
TutorialsCursor + Codex Dual-IDE Collaboration: A Practical Methodology for Open-Source Project Customization
A complete methodology for open-source project customization based on real-world experience, detailing the Cursor+Codex dual-IDE workflow, seven-stage process, MVP validation, and AI source code reading techniques.
TutorialsCursor Multi-Agent in Practice: Building a Full-Stack Next.js Blog in 50 Minutes
Build a full-stack blog in 50 minutes using Cursor IDE's multi-Agent mode with Next.js, Clerk auth, and Supabase. Learn the 4-phase AI Agent workflow and key integration pitfalls.
TutorialsBuilding an AI Software Factory from Scratch: A Cursor Engineer's Hands-On Experience with Multi-Agent Collaboration
Cursor engineer Eric shares practical insights on building an AI software factory: automation levels, guardrail design, parallel Agent management, and scaling to 1000+ Agents for 24/7 development.