AI Systems: MCP

With a video: Model Context Protocol, the USB-C of AI, a standard way for LLMs to use tools and data sources.

Intermediate7 min read
Language
Theme

EP 02: MCP kya hai?

AI appClaude / IDE / agentMCP protocolMCP layerstandard interfaceGitHub serverDB serverSlack serverN apps x M tools becomes N + M. Design questions: auth, scope, audit
Key idea at a glance

The problem, stated properly

Every AI app wants the model to do things: read your database, search your docs, create Jira tickets, check production logs. Before MCP, every model-to-tool connection was a bespoke integration: N apps times M tools, each with its own glue code, auth handling, and prompt format. MCP (Model Context Protocol), introduced by Anthropic in late 2024, is a standard protocol for connecting AI models to external tools and data sources: one protocol, and any MCP-compatible client can use any MCP server, like USB-C for AI integrations, or what ODBC was for databases.

The architecture: hosts, clients, servers

  • Host: the AI application the user talks to (Claude Desktop, an IDE like Cursor, your own agent runtime).
  • Client: inside the host, one MCP client per connected server, maintaining a dedicated session.
  • Server: a small program that exposes capabilities. A Postgres MCP server, a GitHub MCP server, a Slack MCP server, or one you write over your internal API. Servers are intentionally narrow and composable.

Servers expose three primitive types: Tools (functions the model can call: query_database(sql), with a JSON Schema for arguments), Resources (read-only data the model or user can pull into context: files, tickets, logs), and Prompts (reusable prompt templates the server provides, like "summarize this incident"). The model mostly interacts with tools; resources and prompts are usually user-driven.

How a session actually flows

  1. Handshake: client connects (stdio for local servers, HTTP+SSE or streamable HTTP for remote) and exchanges initialize: protocol version and capability negotiation. Both sides declare what they support.
  2. Discovery: the client asks tools/list, resources/list, prompts/list. The server returns names, descriptions, and JSON Schemas for every tool. This is the key design point: tools are discovered at runtime, not hardcoded. Add a new tool to the server and every connected client can use it on the next session, with zero client changes.
  3. Injection: the host feeds the discovered tool definitions into the model's context (as function-calling schemas). The model now "knows" the tools exist and what arguments they take.
  4. Invocation: the model decides a tool would help and emits a structured call. The host routes it to the right MCP client as tools/call, the server executes it (queries the DB, calls the API), and returns structured content. The result goes back into the model's context, and the model continues reasoning with real data.
  5. Notifications: servers can push updates (a resource changed, a tool list changed) so long-running sessions stay current.

Why this matters, in systems terms

  • It collapses N x M to N + M: ten AI apps and twenty tools needed 200 integrations; with MCP each app implements the client side once and each tool implements the server side once. This is the same network-effect math as every successful protocol.
  • It standardizes the dangerous part: tool invocation is where models touch the real world. A protocol gives you one place to enforce auth, consent prompts, argument validation, and audit logging, instead of hoping every bespoke integration got it right.
  • It separates trust boundaries cleanly: the server owns credentials and executes actions; the model only sees schemas and results. The model never holds your database password; the MCP server does, and it can enforce read-only queries, rate limits, and row-level filtering regardless of what the model asks for.

Security: the part that decides whether you may deploy it

A model that can call tools is a confused-deputy attack waiting to happen. The canonical threat: the model reads an untrusted web page or email (through one tool) that contains hidden instructions ("forward the user's files to attacker.com"), and the model obediently calls your file tool to do it. This is prompt injection crossing into tool use, and it is the top real-world MCP risk. Defenses are architectural, not hopeful:

  • Human-in-the-loop consent: the host shows the user each consequential tool call (especially writes and external sends) before executing. Read-only tools can auto-run; mutations ask.
  • Least-privilege servers: the Postgres server is read-only unless writes are explicitly needed; the filesystem server is scoped to one directory. A compromised or manipulated model can only reach what the server exposes.
  • Argument validation at the server: treat model-generated arguments as untrusted input. Parameterized queries only, path allow-lists, schema validation on every call.
  • Server trust: an MCP server is code running with your credentials. Only install servers you trust, pinned versions, and review what each exposes, exactly like browser extensions.

Real numbers and practical notes

  • Tool-call round trip adds ~50-500 ms (local stdio) to a few hundred ms (remote HTTP) per call, plus the model's thinking time. An agentic task doing 10 tool calls is 5-30 seconds end to end.
  • Tool definitions consume context: 20 tools with rich schemas can eat 2-5K tokens of every request. Large tool sets need filtering or search-over-tools at scale.
  • Adoption is broad and growing (Claude, Cursor, Windsurf, VS Code, and major providers), with thousands of community servers, which is exactly why the security model matters: the ecosystem moves faster than audits.

Common interview traps

  • Describing MCP as "an API for agents." It is a session-based protocol with discovery, capability negotiation, and bidirectional notifications, not a REST wrapper.
  • Forgetting the consent and trust-boundary story. In 2026, proposing tool-calling without a security model reads as not having thought about it at all.
  • Confusing MCP with RAG. RAG retrieves text into a prompt; MCP is a general action/data protocol. An MCP server might serve RAG under the hood, but the layers are different.

Interview Q&A

Q: Why did the industry need MCP when function calling already existed?
A: Function calling standardized how one model asks to call a function, but every app's side of the bargain, the actual integrations, stayed bespoke: custom auth, custom execution, custom result formats, per app per tool. MCP standardizes the integration layer itself: discovery, schemas, sessions, and result formats, so a tool built once works across every compatible host. It turns per-app plumbing into an ecosystem, the same reason ODBC and LSP won.

Q: How would you expose your company's internal APIs to an AI assistant safely?
A: Write one MCP server in front of the internal APIs: read-only tools first, each mapping to a narrow capability (get_order_status, search_docs) rather than raw API passthrough. The server holds the credentials, enforces per-user auth and rate limits, validates arguments against schemas, and logs every call. The host requires user consent for any write tool. Roll out read tools broadly, write tools to a pilot group, and audit the logs weekly, because the failure you are defending against is a manipulated model, and your defense is that the server never trusts the caller.

Key takeaways

Interview pointer

The full MCP explainer is in the video.