---
title: "Claude Code + MCP: The Integration Guide"
description: "Model Context Protocol extends Claude Code with external tools—databases, APIs, custom systems. Here's how to set it up and when it's worth it."
pillar: "Claude Code"
level: "advanced"
date: "2026-01-20"
url: "https://theglitch.ai/academy/claude-code/claude-code-mcp-integration"
---

# Claude Code + MCP: The Integration Guide

Model Context Protocol extends Claude Code with external tools—databases, APIs, custom systems. Here's how to set it up and when it's worth it.


# Claude Code + MCP: The Integration Guide

> **The Glitch's Take:** "MCP is Claude Code's expansion pack. Don't install expansion packs until you've beaten the base game."

**Part of:** [The Complete Guide to Claude Code](/articles/claude-code/claude-code-complete-guide)
**Level:** Advanced
**Reading Time:** 14 minutes

---

## The Point

Model Context Protocol (MCP) connects Claude Code to external systems—databases, APIs, file systems, custom tools. It turns Claude from a code writer into a code writer with superpowers.

But superpowers come with complexity. This guide covers when MCP is worth it, how to set it up, and what to connect.

---

## TL;DR

- **MCP** provides Claude Code with external tool access via standardized protocol
- **Use cases:** Direct database queries, API integrations, custom tooling
- **Setup complexity:** Medium (requires running MCP servers)
- **Worth it when:** You repeatedly need Claude to interact with external systems
- **Skip it when:** You're still learning basic Claude Code workflows

---

## What MCP Actually Is

### The Technical Version

MCP (Model Context Protocol) is an open protocol that standardizes how LLMs connect to external tools and data sources. It defines:

- How tools describe their capabilities
- How requests are made to tools
- How responses are returned to the model
- Security and authentication patterns

### The Practical Version

MCP servers are programs that run alongside Claude. They expose capabilities that Claude can use. When Claude needs to query a database, it asks the MCP server. The server runs the query and returns results.

```
Claude Code → MCP Server → External System
                ↓
           Results returned
                ↓
           Claude uses them
```

---

## MCP Architecture

### Components

| Component | What It Does |
|-----------|--------------|
| **MCP Server** | Runs locally, exposes tools |
| **MCP Client** | Claude Code connects to servers |
| **Tools** | Individual capabilities (query, write, read) |
| **Resources** | Data sources servers can access |

### How It Works

1. You configure Claude to connect to MCP server(s)
2. Server advertises available tools to Claude
3. Claude sees tools as part of its capabilities
4. When Claude needs a tool, it calls the server
5. Server executes and returns results
6. Claude incorporates results into its work

---

## Common MCP Servers

### Official/Community Servers

| Server | Purpose | Complexity |
|--------|---------|------------|
| **Filesystem** | Extended file operations | Low |
| **PostgreSQL** | Direct database queries | Medium |
| **SQLite** | Local database access | Low |
| **GitHub** | Repository, PR, issue management | Medium |
| **Slack** | Channel reading, messaging | Medium |
| **Google Drive** | Document access | Medium |
| **Brave Search** | Web search capabilities | Low |

### Custom Servers

You can build MCP servers for any system:
- Internal APIs
- Custom databases
- Proprietary tools
- Legacy systems

Building custom servers requires TypeScript/Python knowledge and understanding of MCP protocol.

---

## Setting Up MCP

### Prerequisites

- Claude Code working correctly
- Node.js 18+ or Python 3.10+
- Understanding of the external system you're connecting

### Step 1: Install MCP Server

Example with PostgreSQL server:

```bash
npm install -g @modelcontextprotocol/server-postgres
```

### Step 2: Configure Claude

Add to your Claude configuration (location varies by setup):

```json
{
  "mcpServers": {
    "postgres": {
      "command": "mcp-server-postgres",
      "args": ["postgresql://user:pass@localhost/mydb"]
    }
  }
}
```

### Step 3: Verify Connection

Start a Claude session. Ask:

```
What database tools do you have available?
```

Claude should list PostgreSQL query capabilities.

### Step 4: Use the Integration

```
Query the users table and show me users who signed up in the last 7 days.
```

Claude generates and executes the SQL.

---

## Real-World MCP Use Cases

### Use Case 1: Database-Aware Development

**Setup:** PostgreSQL MCP server connected to dev database

**Workflow:**
```
"I need to add a new column to track user preferences.
Show me the current users table schema, then generate
the migration and update the User model to match."
```

Claude:
1. Queries schema via MCP
2. Generates migration file
3. Updates model code
4. Verifies consistency

**Without MCP:** You copy schema manually, hope it's current, iterate on mismatches.

### Use Case 2: GitHub-Integrated Development

**Setup:** GitHub MCP server with repo access

**Workflow:**
```
"Look at issue #234. Implement the feature request,
create a branch, and open a draft PR."
```

Claude:
1. Fetches issue details via MCP
2. Creates feature branch
3. Implements the feature
4. Opens PR with description from issue

**Without MCP:** You copy issue details, manually manage git operations outside Claude.

### Use Case 3: Documentation Sync

**Setup:** Google Drive MCP server with docs access

**Workflow:**
```
"Read the API spec from our Google Drive architecture doc
and update the code to match the new endpoint definitions."
```

Claude:
1. Fetches current spec via MCP
2. Compares to existing code
3. Updates endpoints to match spec
4. Reports changes made

**Without MCP:** You export the doc, paste relevant sections, manually track versions.

### Use Case 4: Slack-Driven Development

**Setup:** Slack MCP server with channel access

**Workflow:**
```
"Read the last 20 messages in #bug-reports and create
GitHub issues for any unaddressed bugs."
```

Claude:
1. Fetches Slack messages via MCP
2. Identifies bug reports
3. Creates GitHub issues (via GitHub MCP)
4. Reports what was created

**Without MCP:** Manual triage, copy-paste from Slack to GitHub.

---

## MCP Security Considerations

### What MCP Servers Can Access

MCP servers run with your local permissions. A database server has your database credentials. A filesystem server has your file access.

### Security Principles

1. **Least privilege:** Give servers minimum necessary access
2. **Read-only when possible:** Use read-only database users
3. **Scope credentials:** Don't use admin credentials
4. **Network isolation:** Run servers on localhost only
5. **Audit logs:** Enable logging for compliance needs

### Configuration Example (Secure)

```json
{
  "mcpServers": {
    "postgres-readonly": {
      "command": "mcp-server-postgres",
      "args": ["postgresql://readonly_user:pass@localhost/mydb"]
    }
  }
}
```

### What NOT to Do

- Don't connect production databases with write access
- Don't expose MCP servers to network
- Don't use shared/admin credentials
- Don't connect systems with sensitive data unless necessary

---

## Building Custom MCP Servers

### When to Build Custom

Build custom servers when:
- No existing server for your system
- You need custom tool combinations
- You need specific security constraints
- Integration with internal tools

### Server Structure (TypeScript)

```typescript
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

const server = new Server({
  name: "my-custom-server",
  version: "1.0.0"
}, {
  capabilities: {
    tools: {}
  }
});

// Define tools
server.setRequestHandler("tools/list", async () => ({
  tools: [{
    name: "my_tool",
    description: "Does something useful",
    inputSchema: {
      type: "object",
      properties: {
        param: { type: "string", description: "Input parameter" }
      },
      required: ["param"]
    }
  }]
}));

// Handle tool calls
server.setRequestHandler("tools/call", async (request) => {
  if (request.params.name === "my_tool") {
    const result = await doSomething(request.params.arguments.param);
    return { content: [{ type: "text", text: result }] };
  }
});

// Start server
const transport = new StdioServerTransport();
await server.connect(transport);
```

### Best Practices

1. **Clear tool descriptions** — Claude uses these to decide when to use tools
2. **Typed inputs** — JSON Schema for parameters
3. **Graceful errors** — Return helpful error messages
4. **Logging** — Debug and audit trail
5. **Timeouts** — Don't let operations hang

---

## MCP Troubleshooting

### Server Won't Connect

```
Error: MCP server connection failed
```

**Check:**
1. Server is installed: `which mcp-server-postgres`
2. Config path is correct
3. Server starts manually: run command directly
4. Credentials are valid

### Tools Not Appearing

```
Claude doesn't mention database tools when asked
```

**Check:**
1. Server connected (restart Claude session)
2. Server outputs tools correctly (test standalone)
3. No config syntax errors

### Slow Tool Execution

**Check:**
1. Network latency to external system
2. Query complexity (database)
3. Server resources (CPU/memory)

### Permission Errors

**Check:**
1. Credentials have necessary access
2. Network allows connection
3. Firewall rules permit traffic

---

## Should You Use MCP?

### Use MCP If:

- You repeatedly need Claude to access external data
- Manual data transfer is a significant bottleneck
- You're comfortable running local servers
- Security implications are acceptable

### Don't Use MCP If:

- You're still learning basic Claude Code
- The integration is one-time or rare
- Security constraints prohibit external connections
- Complexity isn't worth the time savings

### The Decision Matrix

| Scenario | MCP Worth It? |
|----------|---------------|
| Query database once per day | Probably not |
| Build features against live schema | Yes |
| Occasional GitHub operations | No |
| Daily PR management workflow | Yes |
| Read one Google Doc | No |
| Continuous doc-to-code sync | Yes |

---

## Quick Reference

### Setup Checklist

- [ ] External system accessible
- [ ] MCP server installed
- [ ] Credentials configured (least privilege)
- [ ] Claude config updated
- [ ] Connection verified
- [ ] Security reviewed

### Common Servers & Install

| Server | Install |
|--------|---------|
| Filesystem | `npm i -g @modelcontextprotocol/server-filesystem` |
| PostgreSQL | `npm i -g @modelcontextprotocol/server-postgres` |
| SQLite | `npm i -g @modelcontextprotocol/server-sqlite` |
| GitHub | `npm i -g @modelcontextprotocol/server-github` |

### MCP Resources

- [MCP Specification](https://spec.modelcontextprotocol.io)
- [Official Server Repository](https://github.com/modelcontextprotocol/servers)
- [Server Development Guide](https://modelcontextprotocol.io/docs/server-development)

---

## Next Steps

- [Debugging in Claude Code](/articles/claude-code/debugging-claude-code)
- [Building Your Context Layer](/articles/claude-code/building-context-layers)
- [Back to Claude Code Guide](/articles/claude-code/claude-code-complete-guide)

---

## Sources

- [Model Context Protocol Specification](https://spec.modelcontextprotocol.io)
- [Anthropic MCP Announcement](https://www.anthropic.com/news/model-context-protocol)
- [MCP Servers Repository](https://github.com/modelcontextprotocol/servers)

---

*Last verified: 2026-01-20. Tested with PostgreSQL, GitHub, and custom MCP servers.*

