Skip to content

MCP Servers

The Model Context Protocol (MCP) lets you connect Claude Code with external tools: databases, APIs, browsers, cloud services, and much more.

What is MCP?

MCP (Model Context Protocol) is an open standard created by Anthropic that defines how AI models communicate with external tools. It's like a "USB for AI": a universal connector that any tool can implement.

With MCP, Claude Code can access resources beyond your local file system: PostgreSQL databases, REST APIs, the web browser, Slack, GitHub, Jira, and any service that has an MCP server.

How it works

An MCP server is a process (local or remote) that exposes:

  • Tools: functions Claude can call (e.g., run SQL, search Slack).
  • Resources: data Claude can read (e.g., DB schema, documentation).
  • Prompts: specialized instructions for specific tasks.

Adding an MCP server

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

Terminal
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres",
               "postgresql://localhost/midb"],
      "env": {}
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxx"
      }
    }
  }
}

Or add servers directly from the CLI:

Terminal
claude mcp add <name> -- <command> [args...]

# Example: PostgreSQL server
claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres \
  "postgresql://localhost/midb"

# Example: filesystem server (read-only)
claude mcp add files -- npx -y @modelcontextprotocol/server-filesystem \
  /path/to/directory

Popular MCP servers

Managing MCP servers

Terminal
# List configured servers
claude mcp list

# View details for a server
claude mcp get postgres

# Remove a server
claude mcp remove postgres

# Inside Claude Code, view active servers:
/mcp

MCP server scopes

MCP servers have three possible scopes:

  • Local (default): available only in the current project. Saved in .claude/settings.json .
  • User: available across all your projects. Saved in ~/.claude/settings.json . Add --scope user to the command.
  • Project: shared with the team via version control.
Terminal
# Add server at user level (global)
claude mcp add --scope user github -- npx -y @modelcontextprotocol/server-github

Creating your own MCP server

Any script that implements the MCP protocol can be a server. Anthropic provides SDKs for Python and TypeScript:

Terminal
# TypeScript
npm install @modelcontextprotocol/sdk

# Python
pip install mcp

Minimal TypeScript example

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

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

server.setRequestHandler("tools/list", async () => ({
  tools: [{
    name: "greet",
    description: "Greets the user",
    inputSchema: {
      type: "object",
      properties: { name: { type: "string" } },
      required: ["name"]
    }
  }]
}));

server.setRequestHandler("tools/call", async (request) => {
  if (request.params.name === "greet") {
    return { content: [{ type: "text", text: `Hello, ${request.params.arguments.name}!` }] };
  }
});

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

MCP in the cloud vs local

MCP servers can run locally (as a process on your machine) or in the cloud (connected via HTTP/SSE). Claude Code supports both:

Terminal
# Local server (stdio)
{
  "command": "node",
  "args": ["./my-mcp-server.js"]
}

# Remote server (HTTP/SSE)
{
  "url": "https://my-server.com/mcp",
  "headers": { "Authorization": "Bearer TOKEN" }
}
Complete Aulafy mapSee how this lesson fits without leaving your path.

Complete Aulafy map

How all courses connect

This is not a checklist. Start with the foundation, choose an outcome, and go deeper only when your project needs more control.

  1. 1Understand
  2. 2Apply or build
  3. 3Operate with confidence
01

Choose an application

Turn the foundation into a visible outcome: a website, a business improvement, media, or an interactive experience.

Continue into the technical branch when you need to maintain code, data, or infrastructure.

02

Build with code

Prepare your environment, work with coding agents, and run models while keeping control of your projects.

This branch prepares you to design and operate reliable AI systems.

03

Take systems to production

Combine retrieval, agents, evaluation, security, deployment, and model adaptation when the problem requires it.

You do not need every course: choose the component your system needs and return as it grows.

View full catalogue