MCP in Claude Code
The Model Context Protocol (MCP) is an open standard that lets Claude connect directly to your databases, APIs, and services. Instead of copy-pasting data into chat, Claude reads and acts on the live source.
Why MCP matters
Without MCP, getting Claude to work with external data means pasting that data into the chat manually — error-prone, tedious, and limited by what fits in the message. MCP removes that friction by giving Claude a direct connection to the source.
| Approach | Steps |
|---|---|
| Without MCP |
|
| With MCP |
|
How MCP works
An MCP server is a small process that sits between Claude and an external system. It exposes a standard set of tools, resources, and prompts that Claude can call. Claude Code manages starting and stopping these servers automatically.
| Step | Role | What happens |
|---|---|---|
| 1 | You | Send a natural-language request |
| 2 | Claude Code | Decides which MCP tool to call |
| 3 | MCP server | Translates the request to an API or DB call |
| 4 | External tool | Returns data from the database, API, or service |
The protocol is open source. Anyone can build an MCP server for their tool. Hundreds of community servers already exist on GitHub for databases, SaaS apps, local utilities, and more.
Transport types
When you add an MCP server you choose how Claude connects to it. Pick HTTP for cloud services, stdio for local tools, and avoid SSE (it is deprecated).
| Transport | Status | Best for | Example command |
|---|---|---|---|
| HTTP | Recommended | Cloud services, SaaS APIs, hosted MCP servers | claude mcp add --transport http my-service https://mcp.example.com/mcp |
| stdio | Local tools | Databases, local scripts, filesystem tools | claude mcp add --transport stdio my-tool -- npx -y some-mcp-package |
| SSE | Deprecated | Legacy servers that have not moved to HTTP yet | claude mcp add --transport sse legacy-service https://example.com/sse |
Worked example: query your dev database
This example connects Claude to a local SQLite database so you can ask questions about your data in plain English instead of writing SQL by hand. It uses the stdio transport because the database lives on your machine.
Add the SQLite MCP server
The -- (double dash) separates Claude's flags from the command that launches the MCP server process. Everything after it is passed directly to the server.
devdb is just a label you choose. It appears in /mcp and in tool call logs so you can identify which server handled each request.Check the connection inside Claude Code
Run /mcp in any Claude Code session to see the status of every connected server. A green indicator means it is running and ready to use.
Ask Claude about your data
Claude now has access to your database. Ask questions in natural language — it will call the right tool internally and return the answer.
Installation scopes
Scope controls who can use the server and whether its configuration is shared with your team. Use the --scope flag when adding a server.
| Scope | Flag | Stored in | Shared? |
|---|---|---|---|
| local | --scope local (default) | ~/.claude.json | Private to you |
| project | --scope project | .mcp.json in project root | Team-shared via Git |
| user | --scope user | ~/.claude.json | Private to you |
The generated .mcp.json file (project scope)
Authenticating with remote servers
Many cloud MCP servers require you to log in before Claude can use them. Claude Code handles this through /mcp — the built-in server management command.
| Method | Steps | Notes |
|---|---|---|
| OAuth 2.0 (browser flow) |
| Works for most hosted services. Tokens refresh automatically in the background. |
| API key / Bearer token |
| Best for services that issue long-lived API keys rather than OAuth tokens. |
Key commands
All server management happens through the claude mcp sub-command in your terminal, and through /mcp inside a Claude Code session.
| Command | What it does |
|---|---|
claude mcp add --transport http name url | Add a remote HTTP MCP server |
claude mcp add --transport stdio name -- cmd | Add a local stdio MCP server |
claude mcp list | Show all configured servers |
claude mcp get <name> | Show details for one server |
claude mcp remove <name> | Remove a server from config |
/mcp | View server status and authenticate inside a session |
What you can ask once connected
Once an MCP server is running, Claude treats its tools as first-class capabilities — just like its built-in file editing and code search. Phrase requests in plain English and Claude figures out which tool to call.
| Category | Example prompts |
|---|---|
| Database |
|
| Issue tracker |
|
| Monitoring |
|
| Design / Docs |
|
Resources and prompts
MCP servers can expose more than just tools. They can also provide resources (data you reference with @) and prompts (canned workflows you call with /).
Resources — @mention
Type @ in your prompt to see available resources from all connected servers.
Prompts — /mcp__commands
MCP prompts become slash commands in the format /mcp__servername__promptname.
Before you continue
- MCP gives Claude a direct connection to databases, APIs, and external services.
- Use HTTP for cloud servers, stdio for local tools, and project scope to share with your team.
- Manage servers with
claude mcpin the terminal and/mcpinside a session. - Resources use
@; MCP prompts appear as/mcp__server__promptslash commands. - Next lesson: Hooks — automatic scripts that run before or after Claude takes an action.
What's Next
MCP opens Claude Code to any external service. Next: Hooks — automatic scripts that run before or after Claude takes an action.