Learning CenterClaude Code MasteryBuilding with MCP Servers
Advanced10 min read

Building with MCP Servers

Extend Claude Code with Model Context Protocol servers — connecting databases, APIs, and custom tools.

What is MCP?

Model Context Protocol (MCP) is an open standard that lets Claude Code connect to external tools, databases, and services via a standardized interface. Instead of writing custom integrations, you install an MCP server and Claude gets immediate access to its capabilities.

Installing an MCP Server

MCP servers are configured in ~/.claude/settings.json:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..."
      }
    }
  }
}

Restart Claude Code and the server's tools are immediately available.

Popular MCP Servers

| Server | What It Provides | |--------|----------------| | server-github | PR review, issue creation, code search | | server-postgres | Direct database queries | | server-filesystem | Extended file operations | | server-puppeteer | Browser automation | | server-slack | Slack messages and channels | | server-linear | Issue tracking and project management |

Using MCP Tools in a Session

Once installed, MCP tools appear alongside built-in tools. Ask Claude to use them naturally:

Create a GitHub issue for the bug we just fixed. Title it "Fix JWT expiry calculation"
and include the root cause analysis and the commit hash.

Claude calls the MCP tool, you approve, and the issue is created — no context switching.

Building a Custom MCP Server

If no existing server fits your needs, build one in TypeScript:

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

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

server.setRequestHandler("tools/list", async () => ({
  tools: [{
    name: "query_analytics",
    description: "Query our analytics database",
    inputSchema: { type: "object", properties: { query: { type: "string" } } }
  }]
}));

Composing MCP Servers

The real power comes from composing servers. In one session, Claude can:

  1. Read a Linear ticket (Linear MCP)
  2. Create a branch (Bash/git)
  3. Write the code (Edit tool)
  4. Create a GitHub PR (GitHub MCP)
  5. Post to Slack (Slack MCP)

This end-to-end automation happens in a single conversational session.

Loading…