Task 2.4
MCP Configuration
Project-level vs user-level MCP setup and secrets management
📘What You Need to Know
What Is MCP?
MCP (Model Context Protocol) is an open standard by Anthropic for connecting AI models to external tools and data. Before MCP, every AI integration required custom client code. MCP provides one universal protocol — build an MCP server once, and any MCP-compatible client can discover and use its capabilities.
An MCP server wraps your API, database, or service and declares what it offers: tools (actions that change state), resources (read-only data for context), and prompts (pre-built prompt templates). The AI client discovers the server, reads its capabilities, and interacts through the standard protocol. This is how Claude Code connects to GitHub, databases, Slack, and other services.
Think of MCP as USB-C for AI tools — one standard protocol connects any AI client to any tool server. Exam questions focus on concepts (protocol, resources vs tools), not implementation internals.
Configuration Levels: .mcp.json vs ~/.claude.json
MCP server configuration lives at two levels, and choosing the wrong level is a common exam trap.
Project level (.mcp.json in the repository): shared via version control for team-wide tools. Every developer on the project gets the same MCP server definitions. Use this for team tools like shared database connectors, project-specific APIs, and CI integrations.
User level (~/.claude.json): personal configuration not shared with the team. Use this for individual API keys, personal development tools, and experimental servers you do not want in version control.
Team-shared MCP config → .mcp.json in the project repo. Personal MCP config → ~/.claude.json. Never put secrets in either file as literal values.
Environment Variables and Secrets
API keys and secrets must never appear as hardcoded values in .mcp.json or any version-controlled file. Use ${ENV_VAR} syntax for environment variable expansion — the config references the variable name, and the actual secret lives in the developer's environment or CI secret store.
A typical project-level entry references ${GITHUB_TOKEN} or ${DATABASE_URL} in the server args or env block. Each developer sets these in their shell profile or .env file (gitignored). CI pipelines inject them from the secret manager at build time.
// .mcp.json — project level, team-shared, NO hardcoded secrets
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"database": {
"command": "node",
"args": ["./mcp-servers/db-server.js"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
}
// ~/.claude.json — user level, personal tools
{
"mcpServers": {
"personal-notes": {
"command": "npx",
"args": ["-y", "my-personal-mcp-server"]
}
}
}What MCP Servers Provide
MCP servers expose three capability types that the exam distinguishes:
- •Tools: custom functions the agent can call to perform actions (create issue, send message, update record). These change state and need guardrails.
- •Resources: read-only data and documentation the model reads for context (product catalog, API docs, config files). Safe to access without side effects.
- •Prompts: pre-built prompt templates the server provides for common workflows (code review template, incident report format).
Resources are read-only context; tools perform actions that change state. The exam tests whether you assign read operations to resources and mutations to tools.
MCP Resources vs Tools in Practice
When building an MCP server, declare resources for data the AI should read — product catalogs, knowledge bases, configuration schemas. These are always safe to access and provide context without side effects.
Declare tools for actions that change state — placing orders, sending messages, updating records. These need permission guardrails, input validation, and structured error returns. The AI client can apply different permission rules to resources versus tools.
The restaurant analogy: the menu is a resource (read to decide), the kitchen is a tool (performs the action). You read the menu for information, then use the kitchen by placing an order.
⚠️Exam Traps
Trap: Hardcoding API keys in .mcp.json
Why it's wrong: Secrets in version-controlled files are a critical security vulnerability exposed to the entire team and git history.
Trap: Putting team-shared MCP config in ~/.claude.json
Why it's wrong: User-level config is personal and not version-controlled — teammates will not have the same MCP servers.
Trap: Using an MCP tool for read-only data access
Why it's wrong: Tools imply actions that may change state; read-only data should be MCP resources.
Trap: Storing MCP configuration in the system prompt
Why it's wrong: System prompts are not a configuration mechanism — they cannot launch servers or manage secrets.
✓Concept Check
Where should team-shared MCP server configuration live?
🔨Build Exercise
Beginner25 minutesConfigure an MCP Server
What you'll learn
- •Set up project-level MCP configuration for team sharing
- •Manage secrets securely with environment variable expansion
- •Distinguish MCP tools, resources, and prompts