Guide for connecting MCP (Model Context Protocol) servers to Claude Code with HTTP, stdio, and SSE transports. Covers installation, configuration, authentication, environment variables, and security.
This skill helps you connect MCP (Model Context Protocol) servers to Claude Code, enabling integrations with external services like GitHub, Notion, databases, project management tools, and custom APIs.
When connecting an MCP server, follow this workflow:
claude mcp add command/mcp in Claude Code for OAuth@ and / prefixesModel Context Protocol (MCP) is a standard for connecting AI assistants to external services and data sources. MCP servers provide:
Best for: Remote cloud-based services Protocol: HTTP/HTTPS with JSON-RPC
Basic syntax:
claude mcp add --transport http <name> <url>
Examples:
Notion integration:
claude mcp add --transport http notion https://mcp.notion.com/mcp
GitHub integration:
claude mcp add --transport http github https://mcp.github.com
Custom API with authentication:
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token-here"
Multiple headers:
claude mcp add --transport http api https://api.example.com/mcp \
--header "Authorization: Bearer token" \
--header "X-API-Version: v2"
Advantages:
Best for: Local tools requiring system access Protocol: Standard input/output (stdin/stdout)
Basic syntax:
claude mcp add --transport stdio <name> <command> [args...]
Examples:
Using npx (recommended for Node.js servers):
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/directory
With environment variables:
claude mcp add --transport stdio airtable \
--env AIRTABLE_API_KEY=your-key-here \
-- npx -y airtable-mcp-server
Direct executable:
claude mcp add --transport stdio custom-server -- /usr/local/bin/my-server --arg1 value1
Windows-specific (requires cmd /c wrapper):
claude mcp add --transport stdio github-local -- cmd /c npx -y @modelcontextprotocol/server-github
Python server:
claude mcp add --transport stdio python-server -- python3 /path/to/server.py
Advantages:
Important notes:
-- separator is required before the command-y flag with npx to auto-installcmd /c wrapper for npxStatus: Deprecated - use HTTP servers instead
Syntax (if needed):
claude mcp add --transport sse <name> <url>
Note: SSE (Server-Sent Events) transport is being phased out. Migrate to HTTP servers where available.
Storage: User settings (not shared) Use for: Personal project-specific servers
claude mcp add --transport http notion https://mcp.notion.com/mcp
No --scope flag means local scope.
Storage: .mcp.json in project root (shared via git)
Use for: Team-wide integrations
claude mcp add --transport http github https://mcp.github.com --scope project
Creates: .mcp.json file:
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://mcp.github.com"
}
}
}
Important: Claude Code prompts for approval before using project-scoped servers from .mcp.json files for security.
Storage: User settings (cross-project) Use for: Servers you use across all projects
claude mcp add --transport stdio filesystem \
--scope user \
-- npx -y @modelcontextprotocol/server-filesystem ~/Documents
Available in all projects on your machine.
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://mcp.github.com",
"headers": {
"Authorization": "Bearer ${GITHUB_TOKEN}",
"X-Custom-Header": "value"
}
},
"notion": {
"type": "http",
"url": "https://mcp.notion.com/mcp"
}
}
}
{
"mcpServers": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/allowed/directory"
]
},
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "${DATABASE_URL}"
}
},
"custom-python": {
"type": "stdio",
"command": "python3",
"args": ["/path/to/server.py", "--config", "config.json"],
"env": {
"PYTHONPATH": "/custom/python/path",
"API_KEY": "${MY_API_KEY}"
}
}
}
}
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://mcp.github.com",
"headers": {
"Authorization": "Bearer ${GITHUB_TOKEN}"
}
},
"filesystem": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${HOME}/projects"
]
},
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "${DATABASE_URL:-postgresql://localhost:5432/mydb}"
}
},
"slack": {
"type": "http",
"url": "https://mcp.slack.com",
"headers": {
"Authorization": "Bearer ${SLACK_TOKEN}"
}
}
}
}
Claude Code supports environment variable expansion:
Syntax:
${VAR} - Expands to environment variable value${VAR:-default} - Uses default if variable not setSupported locations:
Examples:
{
"mcpServers": {
"api": {
"type": "http",
"url": "https://api.example.com/mcp",
"headers": {
"Authorization": "Bearer ${API_TOKEN}",
"X-Environment": "${ENVIRONMENT:-production}"
}
},
"local-server": {
"type": "stdio",
"command": "${HOME}/bin/my-server",
"args": ["--config", "${CONFIG_PATH:-/etc/server.conf}"],
"env": {
"LOG_LEVEL": "${LOG_LEVEL:-info}",
"DATA_DIR": "${DATA_DIR}"
}
}
}
}
macOS/Linux (.bashrc, .zshrc):
export GITHUB_TOKEN="ghp_your_token_here"
export DATABASE_URL="postgresql://user:pass@localhost:5432/db"
export API_KEY="your-api-key"
Windows (PowerShell):
$env:GITHUB_TOKEN = "ghp_your_token_here"
$env:DATABASE_URL = "postgresql://user:pass@localhost:5432/db"
Session-specific:
# Set variable before running Claude Code
GITHUB_TOKEN=token DATABASE_URL=url claude
Many cloud-based MCP servers use OAuth 2.0:
Process:
/mcp commandExample:
# Add GitHub server
claude mcp add --transport http github https://mcp.github.com
# In Claude Code session
/mcp
# Opens browser for GitHub authentication
For services using API tokens:
Via header:
claude mcp add --transport http service https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
Via environment variable:
# Set environment variable
export SERVICE_TOKEN="your-token"
# Add server with variable reference
claude mcp add --transport http service https://api.example.com/mcp \
--header "Authorization: Bearer ${SERVICE_TOKEN}"
Public or local servers:
claude mcp add --transport http public https://public-api.example.com/mcp
claude mcp list
Output:
Configured MCP servers:
github (http) - https://mcp.github.com
filesystem (stdio) - npx -y @modelcontextprotocol/server-filesystem
postgres (stdio) - npx -y @modelcontextprotocol/server-postgres
claude mcp get github
Output:
{
"type": "http",
"url": "https://mcp.github.com",
"headers": {
"Authorization": "Bearer ..."
}
}
claude mcp remove github
claude mcp reset-project-choices
Clears your approval decisions for project-scoped servers.
/mcp
Shows:
Type @ in Claude Code to see available resources:
Format:
@server:protocol://resource/path
Examples:
GitHub issue:
Review the implementation in @github:issue://123
Notion page:
Summarize @notion:page://abc123def456
File from filesystem server:
Compare @filesystem:file:///project/src/old.js with current implementation
Database table:
Analyze schema for @postgres:table://users
Type / to discover MCP prompts:
Format:
/mcp__servername__promptname [arguments]
Examples:
GitHub PR review:
/mcp__github__review-pr 123
Notion page creation:
/mcp__notion__create-page "Project Ideas" "Brainstorming session notes"
Database query:
/mcp__postgres__query "SELECT * FROM users WHERE active = true"
# Allow larger outputs (50,000 tokens)
export MAX_MCP_OUTPUT_TOKENS=50000
claude
# Or inline
MAX_MCP_OUTPUT_TOKENS=50000 claude
Use when:
# 10-second timeout (default is 5 seconds)
MCP_TIMEOUT=10000 claude
Use when:
GitHub:
claude mcp add --transport http github https://mcp.github.com
Tools: Create issues, review PRs, manage repositories
Filesystem:
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/Documents
Tools: Read/write files, search directories
PostgreSQL:
claude mcp add --transport stdio postgres \
--env POSTGRES_CONNECTION_STRING=postgresql://localhost:5432/db \
-- npx -y @modelcontextprotocol/server-postgres
Tools: Query database, analyze schema
Slack:
claude mcp add --transport http slack https://mcp.slack.com
Tools: Send messages, search history, manage channels
Google Drive:
claude mcp add --transport http gdrive https://mcp.google.com/drive
Tools: Access files, search documents, manage folders
Brave Search:
claude mcp add --transport stdio brave-search \
--env BRAVE_API_KEY=your-key \
-- npx -y @modelcontextprotocol/server-brave-search
Tools: Web search, fact-checking
Git:
claude mcp add --transport stdio git -- npx -y @modelcontextprotocol/server-git
Tools: Repository operations, commit history, diff analysis
Sentry:
claude mcp add --transport http sentry https://mcp.sentry.io \
--header "Authorization: Bearer ${SENTRY_TOKEN}"
Tools: Error monitoring, stack trace analysis
Linear:
claude mcp add --transport http linear https://mcp.linear.app
Tools: Issue tracking, project management
Notion:
claude mcp add --transport http notion https://mcp.notion.com/mcp
Tools: Page creation, database queries, content search
Airtable:
claude mcp add --transport stdio airtable \
--env AIRTABLE_API_KEY=your-key \
-- npx -y airtable-mcp-server
MongoDB:
claude mcp add --transport stdio mongodb \
--env MONGODB_URI=mongodb://localhost:27017 \
-- npx -y mongodb-mcp-server
Redis:
claude mcp add --transport stdio redis \
--env REDIS_URL=redis://localhost:6379 \
-- npx -y redis-mcp-server
AWS:
claude mcp add --transport stdio aws \
--env AWS_PROFILE=default \
-- npx -y aws-mcp-server
Administrators can deploy centralized configurations:
macOS:
/Library/Application Support/ClaudeCode/managed-mcp.json
Windows:
C:\ProgramData\ClaudeCode\managed-mcp.json
Linux:
/etc/claude-code/managed-mcp.json
managed-settings.json:
{
"mcpServers": {
"allowlist": ["github", "slack", "notion"],
"denylist": ["unapproved-server"]
}
}
Controls which servers users can configure.
CRITICAL WARNING: "Use third party MCP servers at your own risk - Anthropic has not verified the correctness or security of all these servers."
Before installing:
Servers that fetch untrusted content (web search, user input) can expose Claude to prompt injection attacks.
Mitigation:
Best practices:
Bad practice:
{
"mcpServers": {
"api": {
"headers": {
"Authorization": "Bearer hardcoded-token-123"
}
}
}
}
Good practice:
{
"mcpServers": {
"api": {
"headers": {
"Authorization": "Bearer ${API_TOKEN}"
}
}
}
}
Claude Code prompts before using servers from .mcp.json:
Prompt:
This project wants to connect to the following MCP servers:
- github (https://mcp.github.com)
- filesystem (local file access)
Do you trust these servers?
[Allow for this session] [Always allow] [Never allow]
Review before approving:
Check configuration:
claude mcp list
claude mcp get server-name
Verify:
For OAuth:
/mcp
Re-authenticate through browser
For API tokens:
echo $TOKEN_NAMEIncrease timeout:
MCP_TIMEOUT=15000 claude
Check:
Verify server is connected:
/mcp
Check:
Increase output limit:
MAX_MCP_OUTPUT_TOKENS=50000 claude
Alternative:
Use cmd /c wrapper:
claude mcp add --transport stdio server -- cmd /c npx -y package-name
claude mcp list
Confirm server appears in the list.
claude mcp get server-name
Verify configuration is correct.
Start Claude Code and run:
/mcp
Confirm:
Type @ and verify server resources appear:
@server-name:
Type / and verify server prompts appear:
/mcp__server-name__
Try a simple server operation:
/mcp__github__list-repos
GitHub + Filesystem + Git:
# GitHub for issues and PRs
claude mcp add --transport http github https://mcp.github.com
# Filesystem for project access
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/projects
# Git for version control
claude mcp add --transport stdio git -- npx -y @modelcontextprotocol/server-git
Usage:
PostgreSQL + MongoDB:
# PostgreSQL
claude mcp add --transport stdio postgres \
--env POSTGRES_CONNECTION_STRING=${DATABASE_URL} \
-- npx -y @modelcontextprotocol/server-postgres
# MongoDB
claude mcp add --transport stdio mongodb \
--env MONGODB_URI=${MONGO_URL} \
-- npx -y mongodb-mcp-server
Usage:
/mcp__postgres__query "SELECT ..."Linear + Slack + Notion:
# Linear for issues
claude mcp add --transport http linear https://mcp.linear.app
# Slack for communication
claude mcp add --transport http slack https://mcp.slack.com
# Notion for documentation
claude mcp add --transport http notion https://mcp.notion.com/mcp
Usage:
/mcp__linear__create-issue/mcp__slack__send-messageSentry + Logs:
# Sentry for error tracking
claude mcp add --transport http sentry https://mcp.sentry.io \
--header "Authorization: Bearer ${SENTRY_TOKEN}"
# Custom log server
claude mcp add --transport stdio logs -- python3 ~/mcp-servers/log-analyzer.py
Usage:
/mcp__logs__search "authentication failed"When connecting an MCP server:
claude mcp list, /mcp)When user asks to connect an MCP server:
claude mcp add commandclaude mcp list and claude mcp get/mcp in Claude Code sessionRemember: MCP servers extend Claude's capabilities by connecting to external services. Always verify server trust, use environment variables for secrets, and test thoroughly before relying on server integrations.