A JOURNAL OF ARTIFICIAL INTELLIGENCE
my ai daily

Claude MCP Setup: Connect Tools via CLI and .mcp.json

Configure Anthropic’s Model Context Protocol inside Claude Code using claude mcp add syntax, local/project/user precedence scopes, interactive trust approvals, and zero-secret ${VAR} environment expansion.

AI-generated editorial illustration showing a copper terminal connector routing through three concentric configuration scopes into external database cylinders and key vaults.
AI-generated illustration / my ai dailyIllustrative image.

THE STORY IN THREE POINTS

  • Claude Code connects external databases, issue trackers, and internal APIs via claude mcp add across remote HTTP (recommended), SSE, WebSocket, and local stdio transports—requiring the -- delimiter before stdio binaries so server flags do not collide with Claude CLI flags.
  • Configuration resolves strictly in three descending scopes with zero property merging: local (default inside ~/.claude.json per project path), project (.mcp.json committed to Git with first-run team trust approval), and user (~/.claude.json across every repo).
  • Shared .mcp.json manifests must wrap credentials using ${ENV_VAR} or ${ENV_VAR:-default} runtime expansion inside env and headers fields rather than committing literal tokens into version control.

What is an MCP server—and choosing HTTP vs stdio in Claude Code

For teams asking what is MCP server architecture in daily engineering work, the Model Context Protocol (MCP)—originally open-sourced by Anthropic and stewarded under the Linux Foundation—functions as a typed JSON-RPC bridge linking coding agents directly to live systems rather than static copy-pasted context. Instead of exporting logs or ticket threads manually, connected servers expose executable tools, readable resources, event channels, and reusable prompts straight inside Claude Code’s agentic loop, as detailed in our broader MCP protocol architecture overview.

Claude Code supports four server transport mechanisms via the claude mcp add command. Hosted vendor integrations such as Jira, Notion, or Sentry use streamable remote HTTP (claude mcp add --transport http notion https://mcp.notion.com/mcp, adding --header "Authorization: Bearer token" when required), alongside legacy SSE (--transport sse) and WebSocket connections. Local command-line utilities, database adapters, and npx or uvx scripts launch as managed subprocesses over stdio (--transport stdio). Always place -- before the server executable—for instance, claude mcp add --transport stdio --env API_KEY=val airtable -- npx -y airtable-mcp-server—so server options like --port are forwarded verbatim instead of tripping Claude CLI argument parsing, and keep another flag between --env and the server name because --env consumes multiple KEY=value pairs greedily.

How to set up MCP servers in Claude Code across local, project, and user scopes

Choosing the right --scope (-s) flag determines who inherits your Claude MCP setup and where credentials sit on disk. Local scope (the default when --scope is omitted) writes server entries into ~/.claude.json scoped strictly to your current project directory path—keeping experimental servers or private development keys off teammates’ machines. User scope (--scope user) saves personal cross-repo servers globally inside ~/.claude.json so everyday utilities like note-taking or Slack search follow you across every repository without duplicating setup.

Project scope (--scope project) writes a portable .mcp.json manifest in the repository root with a top-level "mcpServers" JSON object mapping server names to either {"type": "http", "url": "..."} or {"type": "stdio", "command": "...", "args": [...], "env": {...}}. Committing .mcp.json synchronizes identical internal docs and staging database tools for every engineer who clones the repo; for safety, Claude Code pauses on first open to display an interactive approval dialog before activating project-scoped servers. When identical server names collide across files, Claude Code applies strict winner-takes-all resolution from highest to lowest precedence: Local -> Project (.mcp.json) -> User (~/.claude.json) -> Plugins and Claude.ai directory connectors.

Securing ${VAR} credentials, verifying with /mcp, and avoiding redirect leaks

Hardcoding personal access tokens or database strings inside a committed .mcp.json file is one of the fastest ways to leak production keys in shared repos. Both Claude Code’s CLI parser and project .mcp.json schema natively evaluate runtime ${ENV_VAR} and fallback ${ENV_VAR:-default} substitutions inside headers and env dictionaries—allowing repositories to declare "GITHUB_TOKEN": "${GITHUB_TOKEN}" or "Authorization": "Bearer ${SEARCH_API_KEY}" in version control while resolving actual secrets purely from each developer’s shell environment.

After adding servers, type /mcp inside an active session (or /debug alongside /context) to confirm connection states, trigger OAuth browser flows, toggle flaky tools off without deleting configuration, or inspect attribution percentages inside /usage (since Claude Code v2.1.222, token attribution logs only requests consuming that server’s outputs). Teams automating multi-agent loops should verify every remote MCP endpoint for prompt-injection hygiene and patch client runtimes promptly against header-leaking redirects—similar to the vulnerability fixed in Antigravity CLI v1.5.9.

Sources: Connect Claude Code to Tools via MCP — Official Reference|Claude Code Docs ↗ Claude Code MCP Setup: Add MCP Servers (2026 Guide)|Alex Cloudstar ↗ Manage Costs Effectively & MCP Token Attribution|Claude Code Docs ↗

THE BROADER CONTEXT · CLAUDE DOSSIER

Explore full product specifications, pricing analysis, and continuous coverage in the Claude Desk Hub. Independent benchmarks available on the AI Intelligence Index and Coding Agents Leaderboard.

02The next story

News

How to Install Claude Code on Windows (Native & WSL2)

Anthropic has deprecated npm install for Claude Code in favor of standalone native installers—yet native Windows lacks OS command sandboxing. Here is when to choose PowerShell vs. WSL2, exact setup commands, and fixes for PATH and Git Bash errors.

Aider vs Claude Code: Git-First CLI vs Subagent Runtime

Both Aider and Claude Code live inside the terminal—yet one treats Git commits as its core contract with any cloud or local model, while the other ships hooks, MCP, and parallel subagents tuned strictly for Anthropic’s top-ranked Claude checkpoints.

Claude vs ChatGPT: Speed, Coding, Writing & Context Limits

As US search interest in Claude surged +347% YoY, Claude 5.5/Fable 5.2 and ChatGPT (GPT-6.2 Astra/Sol) have diverged cleanly: pick ChatGPT for sub-2-second everyday speed, Intelligent UI canvases, and Space collaboration; pick Claude for 1M-token coding and prose discipline.

Follow your curiosity.

EXPLORE THE ARCHIVESOURCES & CONTEXT INCLUDED