Skip to content

Model Context Protocol (MCP) is the open standard stewarded by the Agentic AI Foundation that lets Claude Code, Codex, and Cursor call external tools and read live data—issues, error monitors, browsers, and databases. Because every connected server expands both the prompt-injection surface and context consumption, treat each MCP server as a governed production dependency.

Someone pastes a community MCP snippet into a project README, half the team runs it with write access, nobody audited the publisher, and an agent edits a live customer ticket after reading an untrusted comment. This guide helps developers integrate MCP cleanly and equips tech leads to govern shared repository servers without blowing the context budget.

An MCP host (your coding agent) opens client connections to one or more servers, each exposing tools (actions), resources (data), and prompts. Tool names and schemas load into model context so the agent can decide when to invoke them, and every returned payload consumes working context on subsequent turns.

NeedPreferred transport or layerWhy
Hosted SaaS (GitHub, Sentry, Linear, Figma, Cloudflare, PostHog)Streamable HTTP remote server with OAuthVendor-maintained auth, zero local secret files, no unmanaged child binaries (avoid legacy HTTP+SSE for new setups)
Local database, private filesystem, or internal toolingstdio local processKeeps local data off external endpoints while honoring local environment isolation
Tooling with a fast CLI already on PATH (such as git or gh)Direct CLI over MCPZero always-on tool schema overhead and predictable stdout filtering
Repeatable engineering procedure without live stateAgent Skill (SKILL.md)Loads instructions on demand with no server or credential surface

Project-level MCP configs belong in version control without embedded credentials:

AgentCommitted project configTrust and approval posture
Claude Code.mcp.json at repository rootPrompts the developer to approve project servers; supports tool-level deny rules in .claude/settings.json
Codex.codex/config.toml ([mcp_servers.*])Loaded only after the project is explicitly trusted; supports per-server enabled_tools and disabled_tools
Cursor.cursor/mcp.jsonManaged alongside workspace MCP settings and per-server authentication prompts

Consult the Model Context Protocol specification alongside the official Claude Code, OpenAI Codex, and Cursor documentation for current protocol revisions, OAuth flows, and CLI commands.

A four-step team workflow for adding MCP servers

Section titled “A four-step team workflow for adding MCP servers”

A personal config experiment affects one developer. A committed project config executes on every teammate’s laptop and CI runner, so it deserves the same review bar as a runtime package.

  1. Verify provenance first. Confirm the official publisher in the MCP registry and on the vendor’s documentation before trusting any URL or package name. Reject typosquatted or abandoned community wrappers when an official hosted Streamable HTTP server exists.

  2. Default strictly to read-only. Enable the server’s own read-only endpoint or flag first (such as read-only URLs or restricted database modes). Where a server lacks a server-side switch, block write tools on the client side via allowlists or deny policies.

  3. Commit secret-free project configuration. Keep .mcp.json, .codex/config.toml, and .cursor/mcp.json completely free of API keys. Prefer per-developer OAuth for remote servers and environment-variable references for local or token-based servers.

  4. Gate config files with CODEOWNERS. Route every MCP configuration pull request through platform engineering or a tech lead who verifies publisher identity, transport, read-only posture, and data reach.

# MCP servers are dependencies: platform owners approve every change
/.mcp.json @acme/platform-owners
/.codex/config.toml @acme/platform-owners
/.cursor/mcp.json @acme/platform-owners

Verifying MCP hygiene, security, and context cost

Section titled “Verifying MCP hygiene, security, and context cost”

You do not need to watch every tool invocation to prove an MCP setup matches policy. Four checks produce durable evidence:

  • Resolved config parity: Inspect what each agent actually resolved (transport, URL, headers, tool filters) and diff it against the reviewed repository file so silently ignored keys surface immediately.
  • Context budget delta: Measure session context before and after adding a server. Large API surfaces can consume tens of thousands of tokens if schemas are dumped upfront; prefer servers with compact tool sets or dynamic tool search, and trim unused servers aggressively.
  • Automated security & harness checks: Scan third-party MCP definitions inside an isolated sandbox for tool poisoning and prompt injection, and run npx @wondelai/harness-audit (see the harness audit) to catch inline secrets or unsafe MCP configs locally and in CI.
  • Explicit tool-call reporting: On sensitive workflows, require the agent to list every MCP tool invoked in order; any write call during a read-only audit fails the check automatically.

What breaks when teams connect MCP servers

Section titled “What breaks when teams connect MCP servers”

Indirect prompt injection through fetched data. Symptom: an agent reads an external GitHub issue, Sentry log, or web page via MCP and follows attacker-planted instructions. Recovery: enforce read-only server scopes by default, isolate sensitive credentials, and never load a contributor’s .mcp.json in CI workflows holding secrets (pull_request_target, issue_comment). See the agent threat model.

Tool-selection confusion and context starvation. Symptom: the agent calls the wrong tool or forgets repository instructions mid-session after connecting five overlapping servers. Recovery: remove any server untouched for a week, replace redundant wrappers with direct CLIs, and keep only high-leverage live integrations active.

Committed project configs silently ignored. Symptom: a teammate pulls the repository and sees zero project servers. Recovery: confirm the file sits at the exact path expected (.mcp.json at repo root for Claude Code, not under .claude/), approve project servers in Claude Code, and mark the workspace trusted in Codex.

Protocol or transport mismatch across tools. Symptom: a remote server connects in one coding agent and fails in another, or a CLI flag registers a URL as a broken stdio binary. Recovery: verify Streamable HTTP transport declaration explicitly, check protocol version support against each agent’s official docs, and confirm resolved config after adding any server.

For current protocol revisions, server cards, OAuth registration, and agent CLI syntax, consult modelcontextprotocol.io alongside the Claude Code, OpenAI Codex, and Cursor documentation.

Did this guide help you?

One tap, no sign-in.

not at all a lot