Lesson 14MCP
MCP Configuration
Setup and transport
Configuration Scopes
User
~/.claude/settings.jsonAvailable in all projects
Common servers (GitHub, Slack)
Project
.claude/settings.jsonOnly in this project
Project-specific (DB, API)
Local
.claude/settings.local.jsonLocal, not in git
Secrets and personal settings
💡 Configs are merged: user → project → local
Transport Types
Standard input/output (default)
Pros
- • Simple setup
- • Works locally
- • Secure
Cons
- • Only local servers
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
}
}
}Environment Variables
Use environment variables for secrets with $VAR_NAME syntax:
"env": {
"GITHUB_TOKEN": "$GITHUB_TOKEN",
"DATABASE_URL": "$DATABASE_URL"
}Method 1: .env file
GITHUB_TOKEN=ghp_xxx
DATABASE_URL=postgresql://...
DATABASE_URL=postgresql://...
Method 2: Shell export
export GITHUB_TOKEN=ghp_xxx
export DATABASE_URL=postgresql://...
export DATABASE_URL=postgresql://...
⚠️ Never commit secrets in settings.json! Use environment variables.
Full Configuration Example
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "$GITHUB_TOKEN"
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_URL": "$DATABASE_URL"
}
},
"brave-search": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-brave-search"],
"env": {
"BRAVE_API_KEY": "$BRAVE_API_KEY"
}
}
}
}Configuration Best Practices
- 1.Secrets — in environment variables or settings.local.json
- 2.Common servers (GitHub) — in user config
- 3.Project-specific (DB) — in project config, but without secrets
- 4.Add .claude/settings.local.json to .gitignore
This lesson is part of a structured LLM course.
My Learning Path