MCP Server Setup

Connect AI coding agents to external tools via Model Context Protocol.

Last updated

Workflow

1. What is MCP

Model Context Protocol is an open standard for connecting AI applications to external data sources and tools. Think of it as USB-C for AI: one protocol that lets any compliant host talk to any compliant server, regardless of vendor.

Three primitives

PrimitiveControlled byPurpose
ToolsModelExecutable functions the AI can call (search, create file, run query)
ResourcesApplicationRead-only data the host app exposes to the model (file contents, DB rows)
PromptsUserReusable prompt templates with arguments (slash commands, workflows)

Client-server architecture

The AI application (the host) creates one MCP client per server. Each client maintains an independent connection, keeping servers isolated from each other. The host orchestrates which servers to consult based on the task.

MCP is supported by Claude Code, ChatGPT, VS Code, Cursor, Windsurf, and many other AI development tools.

2. Adding Servers to Claude Code

Remote server (HTTP transport)

claude mcp add --transport http github-remote https://api.githubcopilot.com/mcp/

Local server (stdio transport)

claude mcp add --transport stdio filesystem npx -- \
  -y @modelcontextprotocol/server-filesystem /home/user/projects

Three config scopes

ScopeFlagLocationShared
Local--scope local (default).claude/settings.local.jsonNo (gitignored)
Project--scope project.mcp.json in repo rootYes (version-controlled)
User--scope user~/.claude/settings.jsonAll projects

Shared project config: .mcp.json

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
      "env": {
        "API_TOKEN": "${API_TOKEN}",
        "LOG_LEVEL": "${LOG_LEVEL:-info}"
      }
    }
  }
}

Environment variables expand at runtime: ${VAR} for required values, ${VAR:-default} for optional ones with fallbacks.

Import from Claude Desktop

claude mcp add-from-claude-desktop

Pulls all servers from your Claude Desktop config into Claude Code. Useful when migrating an existing setup.

3. Transports: stdio vs HTTP

MCP defines two transport mechanisms. The choice depends on whether your server runs locally or remotely.

stdio

The client launches the server as a child process and communicates over stdin/stdout using JSON-RPC. No network stack involved. This is the simplest transport and the default for local tools.

Streamable HTTP

The server runs as an independent HTTP process. Supports OAuth 2.0 for authentication, session management via the Mcp-Session-Id header, and Origin validation to prevent unauthorized browser-based requests. Best for shared or remote servers.

PropertystdioStreamable HTTP
StartupClient spawns processServer runs independently
NetworkNone (pipes)HTTP/HTTPS
AuthInherits process envOAuth 2.0
SessionsLifetime of processMcp-Session-Id header
Best forLocal CLI tools, file opsRemote APIs, shared infra
When to use which: If the server accesses local resources (filesystem, local git), use stdio. If it wraps a remote API or will be shared across machines, use HTTP.

4. Useful Servers

Official reference servers

ServerWhat it does
FilesystemFile read/write/search with configurable access controls
GitRepository operations: status, diff, log, commit
MemoryKnowledge graph persistence across sessions
FetchWeb content retrieval and conversion to markdown
Sequential ThinkingStructured multi-step problem solving
TimeTimezone conversions and current time queries

Archived (community-maintained)

Several servers originally in the official repo have been archived and are now community-maintained: GitHub, PostgreSQL, Sentry, Slack, and SQLite. They still work but receive updates from the community rather than Anthropic.

Discovery: Over 40 community platforms catalog MCP servers, including MCPRegistry, mcp-get, MCPHub, Smithery, and Glama. Search these when you need a server for a specific API or service.
Host (Claude Code) → MCP Client → MCP Server → External System Creates clients JSON-RPC Tools/Resources GitHub, DB, per server stdio/HTTP Prompts Filesystem...