MCP Server Configuration & Built-in Tools

Estimated time: 25 minutes

MCP (Model Context Protocol) lets agents access tools running outside the agent process — databases, APIs, filesystems, internal services. This lesson covers MCP server configuration, the project-vs-user distinction, environment variable handling, and the built-in tools (Read, Write, Edit, Bash, Grep, Glob).

Project-Level vs User-Level MCP Config

FileScopeUse for
.mcp.json (in repo)Project — version-controlled, shared with teamStandard team integrations: Jira, GitHub, internal APIs
~/.claude.jsonUser — personal, NOT shared via gitExperimental tools, personal credentials, sandbox servers

Tools from ALL configured servers are available simultaneously. There's no "active server" — the agent sees the union.

The Standard Config Shape

{
  "servers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
    }
  }
}

Environment Variable Expansion — Never Commit Secrets

The ${VAR} syntax expands at runtime. Set GITHUB_TOKEN in your shell environment; the config references it without storing the actual value. This is the only safe way to use credentials in .mcp.json — committing raw tokens to git is a hard fail in any security review.

Choose Existing Community Servers

For standard integrations (Jira, GitHub, Slack, Notion), use community-maintained MCP servers via npx -y @modelcontextprotocol/server-X. Building your own only makes sense for proprietary internal systems. The community servers are tested across thousands of users — your own implementation will lag in coverage.

Resources for Content Catalogs

MCP supports resources in addition to tools. Resources expose static content (documentation, product catalogs, knowledge bases) that the agent can reference without calling a tool. This reduces exploratory tool calls — instead of "list documents, then read document X", the agent sees the catalog directly.

Built-in Tools

ToolUse for
GrepSearching file contents for patterns: function names, error messages, imports
GlobFinding files by path/name patterns: **/*.test.tsx
ReadLoading the full contents of a file
WriteFull file creation or replacement
EditTargeted modification using unique anchor text matching
BashCommand execution for things outside the file-tool surface

Edit Failure Recovery

The Edit tool requires the anchor text (old_string) to be unique in the file. If Edit fails because the anchor matches multiple locations, fall back to Read + Write: read the file, modify in memory, write the full new contents back.

Skills to Develop

  1. Configure project-level MCP servers in .mcp.json with environment-variable expansion for credentials.
  2. Choose community MCP servers over custom builds for standard integrations.
  3. Expose static content as MCP resources to reduce exploratory tool calls.
  4. Pick the right built-in tool for the job: Grep for content, Glob for paths, Read for full files, Edit for targeted changes.
Exam tip: Never commit raw secrets to .mcp.json. Use ${VAR} expansion. If a question describes a credential leak via committed config, the answer involves environment variable references.