How Claude Code reaches outside the machine — live tools, APIs, and data sources behind one protocol: transports, OAuth, scopes, tool search, and code execution at scale.
Chapter 2's memory stores what doesn't change: preferences, conventions, learned context. But your GitHub issues, database rows, and Slack channels change by the minute. MCP (Model Context Protocol) is a standardized way for Claude to access external tools, APIs, and real-time data sources — live access to changing data, not a snapshot.
| Use Memory for | User preferences, conversation history, learned context — persistent, rarely changing |
| Use MCP for | Current GitHub issues, live database queries, real-time services — external, frequently changing |
Claude sends a tool request (list_issues, create_issue) to an MCP server; the server queries or acts on the external service and returns parsed data — real-time, no caching. One protocol, many servers: real-time access, live sync, extensible architecture, secure authentication, tool-based interactions.
| Filesystem | File operations — read, write, delete · auth: OS permissions |
| GitHub | Repository management — list_prs, create_issue, push · auth: OAuth |
| Slack | Team communication — send_message, list_channels · auth: token |
| Database | SQL queries — query, insert, update · auth: credentials |
| Google Docs | Document access — read, write, share · auth: OAuth |
| Asana / Stripe | Project tasks / payment data · auth: API key |
| Memory server | Persistent store — the one ecosystem server that is not real-time |
# HTTP — recommended claude mcp add --transport http notion \ https://mcp.notion.com/mcp # ...with an auth header claude mcp add --transport http secure-api \ https://api.example.com/mcp \ --header "Authorization: Bearer your-token" # stdio — locally running servers claude mcp add --transport stdio myserver \ --env KEY=value -- npx @myorg/mcp-server # SSE — deprecated, still supported claude mcp add --transport sse legacy \ https://example.com/sse
Add an OAuth-enabled server and Claude Code runs the entire authentication flow. For automation, pass --client-id, --client-secret, and --callback-port to pre-configure credentials non-interactively.
| Interactive OAuth | Type /mcp to trigger the browser-based flow |
| Pre-configured clients | Built-in OAuth clients for common services like Notion and Stripe (v2.1.30+) |
| Token storage | Tokens stored securely in your system keychain |
| Step-up auth | Supported for privileged operations |
| Discovery caching | OAuth discovery metadata cached for faster reconnections |
| Metadata override | oauth.authServerMetadataUrl in .mcp.json points discovery at a working OIDC endpoint (must be https; v2.1.64+) |
MCP servers configured in your Claude.ai account are automatically available in Claude Code — anything set up through the web interface works in the terminal with zero additional configuration. (Requires logging in with a Claude.ai account.)
claude mcp add --transport http github \ https://api.github.com/mcp claude mcp list # all servers claude mcp get github # one server's details claude mcp remove github claude mcp reset-project-choices # redo .mcp.json approvals claude mcp add-from-claude-desktop # import Desktop config
{
"mcpServers": {
"api-server": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": {
"Authorization": "Bearer ${API_KEY}"
}
},
"local-server": {
"command": "${MCP_BIN_PATH:-npx}",
"env": {
"DB_URL": "${DATABASE_URL:-postgresql://localhost/dev}"
}
}
}
}
// .mcp.json (project root) { "mcpServers": { "github": { "command": "npx", "args": ["@modelcontextprotocol/server-github"], "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" } } } } > /mcp__github__get_pr 456 Title: Add dark mode support Author: @alice · Status: OPEN Reviewers: @bob, @charlie
| Pull requests | list_prs, get_pr, create_pr, update_pr, merge_pr, review_pr |
| Issues | list_issues, get_issue, create_issue, close_issue, add_comment |
| Repository | get_repo_info, list_files, get_file_content, search_code |
| Commits | list_commits, get_commit, create_commit |
Or skip the file: claude mcp add --transport stdio github -- npx @modelcontextprotocol/server-github after exporting the token.
The course's daily-report workflow: GitHub MCP pulls PR metrics (42 PRs, 2.3h average merge time) → database MCP runs the sales query (247 orders, $12,450) → Claude combines both into an HTML report → filesystem MCP writes it to /reports/ → Slack MCP posts the summary to #daily-reports. One .mcp.json defines all four servers; three env vars carry the credentials.
@modelcontextprotocol/server-filesystem takes the allowed directory as an argument (e.g. /home/user/projects) — list, read, write, edit, search, and delete inside that boundary only.
The course writes @modelcontextprotocol/server-database, but that package isn't published on npm — read it as the generic shape (DATABASE_URL in env, SQL tools exposed) and substitute the real package for your database provider.
| ENABLE_TOOL_SEARCH=auto | Default — activates when tool descriptions exceed 10% of context |
| auto:<N> | Custom threshold of N tools |
| true / false | Always on / all descriptions sent in full |
| "alwaysLoad": true | Per-server opt-out (v2.1.121+) — tools stay loaded every turn; use sparingly |
Requires Sonnet 4+ or Opus 4+ — Haiku models are not supported.
| Prompts → slash commands | A server's prompts appear as /mcp__<server>__<prompt> — a github server's review prompt becomes /mcp__github__review |
| Resources → @ mentions | @server-name:protocol://resource/path (e.g. @database:postgres://mydb/users) pulls MCP resource content inline into context |
| MCP Apps | The first official MCP extension — tool calls return interactive UI (dashboards, forms, visualizations) rendered directly in the chat |
| Elicitation | Servers request structured input mid-workflow via interactive dialogs — confirmations, option lists, required fields (v2.1.49+) |
| Dynamic tool updates | list_changed notifications — servers add, remove, or modify tools live; no reconnect or restart needed |
Claude Code becomes a stdio MCP server for other applications. Another Claude instance can mount it — claude mcp add --transport stdio claude-agent -- claude mcp serve — the basis for multi-agent workflows where one instance orchestrates another.
Plugins bundle servers two ways: a standalone .mcp.json in the plugin root, or inline in plugin.json. ${CLAUDE_PLUGIN_ROOT} resolves paths relative to the plugin's install directory — available automatically when the plugin is installed.
An agent's frontmatter can declare mcpServers: inline — the server exists only inside that agent's execution context, invisible to parent and sibling agents. Give one specialist a tool the rest of the workflow never sees.
{
"allowedMcpServers": [
{ "serverName": "github",
"serverUrl": "https://api.github.com/mcp" },
{ "serverName": "company-internal",
"serverCommand": "company-mcp-server" }
],
"deniedMcpServers": [
{ "serverName": "untrusted-*" },
{ "serverUrl": "http://*" }
]
}
Two sources of waste: tool definitions load upfront (thousands of tools = hundreds of thousands of tokens before your request is even read), and every intermediate result transits the context — a transcript copied from one service to another flows through the model twice, 50,000+ tokens for a 2-hour meeting.
servers/ ├── google-drive/ │ ├── getDocument.ts // typed wrapper │ └── index.ts └── salesforce/ └── updateRecord.ts // agent-written orchestration: const transcript = (await gdrive .getDocument({ documentId: 'abc123' })).content; await salesforce.updateRecord({ objectType: 'SalesMeeting', data: { Notes: transcript } // never touches context });
MCPorter is a TypeScript runtime and CLI toolkit for calling MCP servers without boilerplate — the infrastructure layer for the code-execution approach. Instead of loading every tool from every server, you discover, inspect, and call specific tools on demand.
| Zero-config discovery | Auto-finds servers from Cursor, Claude, Codex, or local configs |
| mcporter emit-ts | Generates .d.ts interfaces + ready-to-run typed wrappers |
| createServerProxy() | Tools as camelCase methods with .text() / .json() / .markdown() helpers |
| generate-cli | Any MCP server → standalone CLI, with --include-tools / --exclude-tools filtering |
| Parameter hiding | Optional params hidden by default — less schema verbosity |
# discover instantly, no install npx mcporter list # call one tool directly npx mcporter call linear.create_comment \ issueId:ENG-123 body:'Looks good!' // compose in TypeScript const runtime = await createRuntime(); const gdrive = createServerProxy( runtime, "google-drive");
MCP puts every external service behind one request loop. Servers arrive over three transports (HTTP first), authenticate via end-to-end OAuth, and live at three scopes where the closest definition wins. The context bill is managed for you — tool search, the 2 KB description cap, output truncation — and at real scale, code execution moves the data flow out of the model entirely: ≈150k tokens down to ≈2k. Servers aren't passive either: they expose slash-command prompts, @-mention resources, inline apps, and mid-task questions — and Claude itself can be one with claude mcp serve.