How Does Claude Code Work? Models, Architecture, and MCP Integration Explained | Code Boost
Description: Claude Code is more than a chatbot that writes code. It is an agentic system that reads your files, executes terminal commands, manages git operations, connects to external service...

Article

# How Does Claude Code Work? Models, Architecture, and MCP Integration Explained

By Matt · Feb 24, 2026

Claude Code is more than a chatbot that writes code. It is an agentic system that reads your files, executes terminal commands, manages git operations, connects to external services, and coordinates with other tools, all while maintaining awareness of your full codebase. Understanding how it works helps you use it more effectively, choose the right model, manage context, and extend it with external tools through MCP. For a general overview of what Claude Code does, see what is Claude Code. To start using it right away, check out how to use Claude Code. Claude Code runs on Anthropic's Claude family of large language models. By default, it uses Claude Sonnet, which balances coding capability and speed well for most development tasks. Subscribers on Max plans also get access to Claude Opus, the most capable model, which excels at complex multi-step reasoning, architectural decisions, and debugging subtle issues. Switch between models during a session with the /model command. Sonnet is faster and cheaper per token, ideal for routine tasks like writing tests, fixing lint errors, and generating boilerplate. Opus takes longer per response but produces higher quality results for challenging problems. Haiku is also available as the fastest, most economical option for simple tasks. The specific model versions evolve as Anthropic ships updates. Claude Code automatically uses the latest versions, so you benefit from improvements without changing any configuration. The models have large context windows allowing Claude Code to process significant amounts of code and conversation history in a single session.

## How Claude Code Processes Your Requests

When you send a message, Claude Code assembles a prompt that includes your system configuration from CLAUDE.md files, conversation history, referenced file contents, and your current request. This prompt goes to the Claude API, which returns a response containing text explanations, code suggestions, or tool use requests. Tool use is what makes Claude Code agentic. The model can request to read files, write files, execute bash commands, search your codebase, and interact with MCP servers. Each tool use requires your approval by default unless you have pre-configured permissions. After a tool executes, the result feeds back to the model for the next step, creating an iterative loop. This means a single request from you might result in Claude Code reading several files, running a test suite, identifying failures, editing code, running tests again, and reporting success, all as part of one interaction. The model decides which tools to use and in what order based on your request and the results at each step.

## Context Windows and Token Management

Every session operates within a context window, the total amount of text the model considers at once. This includes system prompts, CLAUDE.md files, conversation history, file contents, and tool results. As sessions grow, context fills up and needs management. Claude Code handles this through auto-compaction, which summarizes conversation history when approaching limits. You can trigger manual compaction with /compact, optionally specifying what to prioritize. The /clear command discards context entirely for switching to unrelated tasks. Prompt caching reduces both cost and latency. System prompts and CLAUDE.md content that does not change between messages gets cached, so subsequent interactions process faster at reduced cost. This is why well-structured CLAUDE.md files matter for both quality and efficiency. For detailed cost management, see our pricing guide.

## How Claude Code Reads and Edits Your Codebase

Claude Code uses agentic search to understand your codebase rather than requiring manual file selection. When you ask about your project, it searches file names, contents, and structure to find relevant code, working like an AI-powered grep. For file editing, changes are proposed as diffs you review before accepting. In the terminal, diffs display inline. In VS Code and other IDEs, they appear as visual overlays. See our guide on using Claude Code in VS Code for the IDE experience. Claude Code can spawn multiple sub-agents for parallel work. A lead agent coordinates the task and assigns parts to specialized sub-agents, each with their own context window. This is powerful for large refactoring jobs spanning many files.

## How to Add MCP Servers to Claude Code

The Model Context Protocol is an open standard that extends Claude Code beyond your local codebase. By adding MCP servers, you connect Claude Code to GitHub, Jira, Google Drive, Slack, databases, and any custom tooling you build. Add servers with the "claude mcp add" command, specifying the server name, transport type, and connection details. Configure them at the project level in a .mcp.json file in your project root, or globally in your Claude Code settings. Project-level configuration is best for servers specific to one project. Global configuration suits general-purpose servers like Slack or Google Drive. For servers requiring OAuth authentication, Claude Code supports pre-configured client credentials. Use the --client-id and --client-secret flags with "claude mcp add" for servers that do not support Dynamic Client Registration.

## Common MCP Server Setups

GitHub is one of the most popular MCP servers. It lets Claude Code read issues, create branches, open and review pull requests, and manage repository workflows. Combined with code editing, this creates a complete loop from issue to merged PR without leaving your terminal. Google Drive connects Claude Code to your documents, useful for implementing features based on specs stored outside your repo. Slack integration enables automated status updates after completing tasks. Database servers let Claude query your development databases to understand schemas, verify fixes, or generate migrations. Custom MCP servers can wrap any API or internal tool.

## Managing MCP Permissions and Troubleshooting

When you add a server, Claude Code asks permission before using its tools. Pre-configure permissions with wildcard syntax in your settings. "mcp__servername__*" allows all tools from a server, while more granular patterns restrict specific tools. The /permissions command shows and manages your rules. If an MCP server shows as "pending" and never connects, verify the server process is running and accessible from your terminal environment. WSL users should ensure the server is reachable from the Linux side. The /debug command helps troubleshoot connection issues. Servers loaded from .mcp.json can get stuck pending in non-interactive mode with -p, which restarting in interactive mode resolves. Be selective about which servers you connect. Each adds tool definitions to your context, consuming tokens. Five servers with 10 tools each means 50 tool definitions on every message. Only connect servers you actively use. Use project-level .mcp.json so servers only load for relevant projects.

## How to Access Claude Code

Claude Code is accessible through several surfaces. The terminal CLI runs on macOS, Linux, and Windows. IDE extensions work in VS Code, Cursor, Windsurf, and JetBrains. The web interface at claude.ai/code runs in your browser without local installation. Sessions move between surfaces with /teleport. All access methods require a Claude subscription or Anthropic Console account. For pricing details, see our cost guide. To get set up, follow our installation guide and then the configuration walkthrough.