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.
Without MCP
- 1.Open your database client
- 2.Copy query results
- 3.Paste into Claude chat
- 4.Ask your question
- 5.Repeat for every follow-up
With MCP
- 1.Add the MCP server once
- 2.Ask Claude in plain English: "How many users signed up today?"
- 3.Claude queries the database directly
- 4.Done — no copy-pasting ever again
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.
You
Natural language request
Claude Code
Decides which tool to call
MCP Server
Translates to API/DB call
External Tool
Database / API / 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. There are three transport options. Pick HTTP for cloud services, stdio for local tools, and avoid SSE (it's deprecated).
HTTP
RecommendedConnects to remote cloud-hosted MCP servers over HTTPS. Supports OAuth authentication and auto-reconnects if the connection drops.
Best for: Cloud services, SaaS APIs, any hosted MCP server
stdio
Local toolsStarts a local process on your machine and communicates via stdin/stdout. Ideal for database clients, CLI wrappers, and scripts that need filesystem access.
Best for: Databases, local scripts, filesystem tools, dev utilities
SSE
DeprecatedServer-Sent Events transport. It works, but Anthropic recommends switching to HTTP where available. Only use it if the server has not yet added HTTP support.
Best for: Legacy servers that haven't moved to HTTP yet
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 local (default)Private to youAvailable only in the current project, only to you. Good for personal credentials or experimental servers you aren't ready to share.
Stored in: ~/.claude.json
--scope projectTeam-shared via GitSaved in .mcp.json at the project root. Commit this file and every team member gets the same servers automatically when they open the project.
Stored in: .mcp.json in project root
--scope userPrivate to youAvailable to you across every project on your machine. Good for personal utility servers like a note-taking tool or a personal API key.
Stored in: ~/.claude.json
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.
OAuth 2.0 (browser flow)
- 1.Add the server with claude mcp add --transport http
- 2.Run /mcp inside Claude Code
- 3.Claude opens your browser for the login
- 4.Complete login — tokens are saved automatically
Works for most hosted services. Tokens refresh automatically in the background.
API key / Bearer token
- 1.Generate an API key in the service dashboard
- 2.Pass it as a header when adding the server:
- 3.claude mcp add --transport http svc https://mcp.svc.com --header "Authorization: Bearer YOUR_KEY"
- 4.No browser flow needed — key is stored in config
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. You phrase requests in plain English and Claude figures out which tool to call.
🗄️ Database
- "Show me the schema for the orders table"
- "Which products haven't sold in 60 days?"
- "Find duplicate email addresses in users"
🐛 Issue tracker
- "What open bugs are assigned to me?"
- "Create an issue for the error we just found"
- "Summarise all issues closed this sprint"
📊 Monitoring
- "What errors happened in the last hour?"
- "Which page has the highest error rate today?"
- "Show me the stack trace for error ID xyz"
🎨 Design / Docs
- "What changed in the latest Figma design?"
- "Find the API docs for the payment endpoint"
- "Summarise the last three Slack messages in #alerts"
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. Reference them like files:
Prompts — /mcp__commands
MCP prompts become slash commands in the format /mcp__servername__promptname. They work exactly like skills:
Quick Reference
Add HTTP server
Add stdio server
Manage servers
What's Next
MCP opens Claude Code to any external service. Next: Hooks — automatic scripts that run before or after Claude takes an action.