Connecting external tools and data sources with Model Context Protocol
MCP is an open-source standard protocol for connecting AI models with external tools and data sources. It was developed and led by Anthropic, and through MCP, Claude Code can directly integrate with a wide variety of services and tools.
Think of MCP as a "USB port that connects external tools to AI."
For example, if you connect the Notion MCP to Claude Code, you can simply say "Find meeting notes in Notion" and the AI will search Notion directly. If you connect the GitHub MCP, you can just say "Show me the recent PR list."
Without MCP, Claude Code can only work with code files, but with MCP connected, the AI can directly interact with external services such as Notion, GitHub, Slack, databases, and more.
With MCP, Claude Code can directly call external APIs, query databases, or interact with SaaS tools.
There are 3 transport methods for connecting to MCP servers.
If you're unsure, choose HTTP.
The most recommended method. Connects to remote MCP servers via HTTP.
# Connect to Notion MCP server
claude mcp add --transport http notion https://mcp.notion.com/mcp
# Connect to Linear MCP server
claude mcp add --transport http linear https://mcp.linear.app/sseServer-Sent Events method. Used with older versions of MCP servers.
# Connect to Asana MCP server
claude mcp add --transport sse asana https://mcp.asana.com/sseRuns MCP server processes directly on your local machine.
# Filesystem MCP server
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/dir
# GitHub MCP server
claude mcp add --transport stdio github -- npx -y @modelcontextprotocol/server-github
# PostgreSQL MCP server
claude mcp add --transport stdio postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb# List all configured MCP servers
claude mcp list# View configuration details for a specific server
claude mcp get notion# Remove an MCP server connection
claude mcp remove notion# Reset per-project MCP tool permissions
claude mcp reset-project-choicesMCP servers can be installed at 3 different scopes.
Scope determines where the MCP server configuration applies.
For example, if you only use Notion in a specific project, set it with --scope project. If you use GitHub across all projects, set it with --scope user. When starting out, using the default (user) is fine.
| Scope | Config File | Applies To | When to Use |
|---|---|---|---|
| local | ~/.claude.json | Current user, all projects | Personal tools (default) |
| project | .mcp.json | Current project only | Team-shared tools |
| user | User settings | Current user, all projects | Per-user settings |
# Install at project scope (shared with team)
claude mcp add --scope project notion --transport http https://mcp.notion.com/mcp
# Install at local scope (personal use, default)
claude mcp add --scope local github --transport stdio -- npx -y @modelcontextprotocol/server-githubBy creating a .mcp.json file in your project, all team members can use the same MCP servers.
{
"mcpServers": {
"notion": {
"transport": "http",
"url": "https://mcp.notion.com/mcp"
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./docs"]
}
}
}When using Stdio-based MCP servers on Windows (WSL2), you may need a cmd /c wrapper.
# When running npx-based MCP servers on Windows
claude mcp add --transport stdio myserver -- cmd /c npx -y @some/mcp-serverThis is due to path differences between WSL2 and native Windows Node.js. If you're running directly inside WSL2, the wrapper is not needed.
Some MCP servers support OAuth 2.0 authentication. On the first connection, a browser window will automatically open to guide you through the authentication process.
# Sentry MCP server (OAuth authentication)
claude mcp add --transport http sentry https://mcp.sentry.dev/sse
# On first use, a browser opens and you log in with your Sentry account
# After authentication, the token is automatically savedTool Search is a feature that allows Claude Code to automatically find and activate the MCP tools it needs.
# Disable Tool Search
export ENABLE_TOOL_SEARCH=false
# Enable Tool Search (default)
export ENABLE_TOOL_SEARCH=truePrompts provided by MCP servers can be used like slash commands.
/mcp__servername__promptname
# Use the Notion server's search prompt
/mcp__notion__search
# Use the GitHub server's PR review prompt
/mcp__github__review-pr
MCP prompts provide predefined workflows for each server, allowing you to execute complex tasks with simple commands.
MCP Resources can be mentioned with the @ symbol to include them in the context.
# Include a Notion page in the context
@notion:page/project-requirements
# Reference a GitHub issue
@github:issue/123
When you mention a resource, the data is automatically included in Claude's context, allowing you to reference external data without copy-pasting.
Claude Code itself can be run as an MCP server, allowing other MCP clients to connect to it.
# Run Claude Code as an MCP server
claude mcp serveThis allows other AI tools or automation systems to call Claude Code's capabilities via the MCP protocol. For example, you can connect to Claude Code from VS Code's MCP client or other agents.
MCP servers can be managed at the organization level. Through the managed-mcp.json file, you can deploy the same MCP server configuration to all users within an organization.
{
"mcpServers": {
"internal-api": {
"transport": "http",
"url": "https://mcp.internal.company.com/api",
"required": true
},
"sentry": {
"transport": "http",
"url": "https://mcp.sentry.dev/sse",
"required": false
}
}
}# Project management
claude mcp add --transport http linear https://mcp.linear.app/sse
# Document management
claude mcp add --transport http notion https://mcp.notion.com/mcp
# Error monitoring
claude mcp add --transport http sentry https://mcp.sentry.dev/sse
# Local database
claude mcp add --transport stdio postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb
# File browsing
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem ./docs# Check status of all MCP servers
claude mcp list
# Test connection to a specific server
claude mcp get linearAmong the many MCP servers available, here are the 10 most popular and useful ones. Choose the servers that match your project needs to extend Claude Code's capabilities.
| Rank | Server | Purpose | Transport | Installation Command |
|---|---|---|---|---|
| 1 | GitHub | Repository, issue, and PR management | Stdio | claude mcp add --transport stdio github -- npx -y @modelcontextprotocol/server-github |
| 2 | Notion | Documents, databases, and wiki integration | HTTP | claude mcp add --transport http notion https://mcp.notion.com/mcp |
| 3 | Slack | Messaging, channel management, search | Stdio | claude mcp add --transport stdio slack -- npx -y @anthropic-ai/mcp-server-slack |
| 4 | Sentry | Error tracking, performance monitoring | HTTP | claude mcp add --transport http sentry https://mcp.sentry.dev/sse |
| 5 | Playwright | Browser automation, E2E testing | Stdio | claude mcp add --transport stdio playwright -- npx -y @anthropic-ai/mcp-server-playwright |
| 6 | PostgreSQL | Database querying and management | Stdio | claude mcp add --transport stdio postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb |
| 7 | Filesystem | Extended local filesystem access | Stdio | claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/dir |
| 8 | Linear | Project/issue management, sprint tracking | HTTP | claude mcp add --transport http linear https://mcp.linear.app/sse |
| 9 | Figma | Design file viewing, component inspection | Stdio | claude mcp add --transport stdio figma -- npx -y @anthropic-ai/mcp-server-figma |
| 10 | Puppeteer | Web scraping, screenshots, PDF generation | Stdio | claude mcp add --transport stdio puppeteer -- npx -y @anthropic-ai/mcp-server-puppeteer |
Tip: All Stdio-based servers can be run instantly with
npx -ywithout installation. Register frequently used servers in.mcp.jsonto share them with your team.
If you need functionality that existing MCP servers don't provide, you can build your own MCP server. Below is an example of creating a simple MCP server in TypeScript that provides a weather lookup tool (get_weather).
# Create project directory and initialize
mkdir my-weather-mcp && cd my-weather-mcp
npm init -y
npm install @modelcontextprotocol/sdk zod
npm install -D typescript @types/node
npx tsc --initCreate the src/index.ts file.
// src/index.ts
// Main file for the MCP server.
// When Claude Code calls the "get_weather" tool,
// this server returns weather information.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
// Create an MCP server instance
const server = new McpServer({
name: "weather-server", // Server name (displayed in Claude Code)
version: "1.0.0", // Server version
});
// Register the "get_weather" tool
// This tool takes a city name and returns weather information
server.tool(
"get_weather", // Tool name
"Looks up the current weather for a given city", // Tool description (referenced by Claude)
{
city: z.string().describe("City name to look up weather for (e.g., Seoul, Tokyo)"),
},
async ({ city }) => {
// In a real service, you would call a weather API here
// This example returns simple dummy data
const weatherData: Record<string, { temp: number; condition: string }> = {
Seoul: { temp: 12, condition: "Clear" },
Tokyo: { temp: 15, condition: "Cloudy" },
"New York": { temp: 8, condition: "Rainy" },
};
const weather = weatherData[city];
if (!weather) {
return {
content: [
{
type: "text" as const,
text: `Weather data not found for city "${city}".`,
},
],
};
}
return {
content: [
{
type: "text" as const,
text: `Current weather in ${city}: ${weather.temp}°C, ${weather.condition}`,
},
],
};
}
);
// Start the server (using Stdio transport)
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Weather MCP server has started"); // Log output to stderr
}
main().catch(console.error);# Build TypeScript
npx tsc
# Verify it runs (press Ctrl+C to stop)
node dist/index.js# Register your custom MCP server with Claude Code
claude mcp add --transport stdio weather-server -- node /absolute/path/to/my-weather-mcp/dist/index.js
# Verify registration
claude mcp list
# Test usage (inside Claude Code)
# Type "What's the weather in Seoul?" and the get_weather tool will be called automaticallyconsole.error(). console.log() conflicts with MCP protocol messages.claude mcp add ... -e API_KEY=xxx.mcp.json and commit to Git.claude mcp get weather-server.By leveraging MCP effectively, you can expand Claude Code from a simple coding tool into an integrated development platform.