Model Context Protocol (MCP): The Open Standard for AI Tools
The Model Context Protocol (MCP) is an open standard that enables developers to build secure, two-way connections between their data sources and AI-powered tools (like Claude, ChatGPT, or custom agents).
1. Why MCP?
Before MCP, every AI tool had its own proprietary way of connecting to data. This led to fragmented ecosystems. MCP provides a unified way for: - Agents to discover and use tools (APIs, databases). - Users to share context from their local files or workflows. - Enterprise to control exactly what an AI can see and do.
2. Architecture: The Three Pillars
MCP is built on a simple Client-Server architecture.
🏛️ MCP Clients
These are the AI applications (e.g., Claude Desktop, IDE extensions) that consume data and call tools. - Role: Maintains the conversation context and decides when to call a server.
⚙️ MCP Servers
Lightweight programs that expose specific capabilities or data. - Role: Provides Resources, Tools, and Prompts to the client. - Examples: A server that connects to GitHub, a server that reads a local SQLite DB, or a server that fetches Google Search results.
🔌 Transport Layer
MCP supports multiple transport methods: - Stdio: For local servers running as child processes. - SSE (Server-Sent Events): For remote servers over HTTP.
3. Core Concepts
| Concept | Description |
|---|---|
| Resources | Read-only data. Think of it as a file or a database table (e.g., git://repo/readme.md). |
| Tools | Executable functions. The agent can call these to take action (e.g., write_file, search_web). |
| Prompts | Pre-defined templates that help the user or agent structure their interaction. |
4. Example: How an MCP Request Works
- Discovery: The Client asks the Server: "What can you do?"
- Exposure: The Server responds: "I have a tool called
fetch_weather." - Execution: The Client (controlled by an LLM) sends a request:
call_tool("fetch_weather", {"city": "Dubai"}). - Response: The Server executes the logic and returns the data.
5. FAQs for Interviews & Technical Design
- How is MCP different from standard REST APIs?
- REST APIs are static. MCP is agentic. It provides a schema that is specifically designed for LLMs to understand, including descriptions for every field and the ability to discover "Resources" dynamically.
- Is MCP secure?
- Yes. MCP servers run in a sandbox. The Client (and the User) must explicitly approve every tool call. You can restrict sensitive data by never exposing it as a "Resource".
-
Can I build my own MCP server?
- Absolutely. SDKs exist for TypeScript/JavaScript and Python.
- Quick Start (Python): ```python from mcp.server.fastmcp import FastMCP mcp = FastMCP("MyServer")
@mcp.tool() def add(a: int, b: int) -> int: return a + b ```