# Anthropic MCP Specification — Protocol Reference > Official Model Context Protocol specification reference. Understand MCP architecture, message format, tool definitions, resource types, and transport protocols for building servers. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use ```bash # Start building an MCP server npm init -y && npm install @modelcontextprotocol/sdk ``` ```typescript import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; const server = new McpServer({ name: "my-server", version: "1.0.0" }); server.tool("hello", { name: { type: "string" } }, async ({ name }) => ({ content: [{ type: "text", text: `Hello, ${name}!` }], })); const transport = new StdioServerTransport(); await server.connect(transport); ``` ## What is MCP? The Model Context Protocol (MCP) is an open standard by Anthropic that defines how AI applications (clients) connect to external data sources and tools (servers). It standardizes the interface between LLMs and the outside world — similar to how HTTP standardized web communication. MCP enables AI agents to use tools, access resources, and receive prompts from any compliant server. **Answer-Ready**: MCP (Model Context Protocol) is Anthropic's open standard for connecting AI to external tools and data. Defines tools (actions), resources (data), and prompts (templates). JSON-RPC over stdio or HTTP. Used by Claude Code, Cursor, and 200+ servers. The USB-C of AI integrations. **Best for**: Developers building MCP servers or understanding the protocol. **Works with**: Claude Code, Cursor, Claude Desktop, any MCP client. ## Protocol Architecture ### Client-Server Model ``` AI Application (Client) MCP Server ┌─────────────────┐ ┌─────────────────┐ │ Claude Code │ ←JSON→ │ GitHub MCP │ │ Cursor │ RPC │ Database MCP │ │ Claude Desktop │ │ Custom Server │ └─────────────────┘ └─────────────────┘ ``` ### Three Primitives | Primitive | Direction | Purpose | |-----------|-----------|---------| | **Tools** | Client → Server | Actions the AI can perform (search, create, delete) | | **Resources** | Client ← Server | Data the AI can read (files, DB records, API responses) | | **Prompts** | Client ← Server | Reusable prompt templates with parameters | ## Tool Definition ```typescript server.tool( "search_issues", { query: { type: "string", description: "Search query" }, state: { type: "string", enum: ["open", "closed", "all"], default: "open" }, limit: { type: "number", default: 10 }, }, async ({ query, state, limit }) => { const results = await github.searchIssues(query, state, limit); return { content: [{ type: "text", text: JSON.stringify(results) }], }; } ); ``` ## Resource Definition ```typescript server.resource( "file://{path}", async ({ path }) => ({ contents: [{ uri: `file://${path}`, text: await readFile(path, "utf-8") }], }) ); ``` ## Transport Protocols | Transport | Use Case | How | |-----------|----------|-----| | stdio | Local servers | Spawn as child process, communicate via stdin/stdout | | HTTP+SSE | Remote servers | HTTP POST for requests, SSE for notifications | | Streamable HTTP | Modern remote | Full-duplex over HTTP | ### stdio Configuration ```json { "mcpServers": { "my-server": { "command": "node", "args": ["server.js"], "env": { "API_KEY": "..." } } } } ``` ### HTTP Configuration ```json { "mcpServers": { "remote-server": { "transport": "http", "url": "https://api.example.com/mcp" } } } ``` ## Message Format (JSON-RPC 2.0) ```json // Request {"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "search_issues", "arguments": {"query": "bug"}}} // Response {"jsonrpc": "2.0", "id": 1, "result": {"content": [{"type": "text", "text": "..."}]}} ``` ## SDK Languages | Language | Package | |----------|---------| | TypeScript | `@modelcontextprotocol/sdk` | | Python | `mcp` | | Kotlin | `io.modelcontextprotocol:kotlin-sdk` | | C# | `ModelContextProtocol` | ## FAQ **Q: Is MCP only for Anthropic/Claude?** A: No, MCP is an open standard. Cursor, Codex, and other tools support it. **Q: How many MCP servers exist?** A: 200+ and growing. Browse at smithery.ai or the official MCP servers repo. **Q: Can I build a server in Python?** A: Yes, use the `mcp` Python package. Same capabilities as TypeScript SDK. ## Source & Thanks > Created by [Anthropic](https://github.com/modelcontextprotocol). Licensed under MIT. > > [modelcontextprotocol/specification](https://github.com/modelcontextprotocol/specification) — Official MCP spec > [spec.modelcontextprotocol.io](https://spec.modelcontextprotocol.io) — Full specification ## Quick Use ```bash npm install @modelcontextprotocol/sdk ``` Create an MCP server in a few lines of code. ## What is MCP? Anthropic's open standard defining how AI applications connect to external tools and data. Just as HTTP is to the web, MCP is the standard protocol for AI integration. **TL;DR**: Anthropic's open standard. Protocol for AI to connect to external tools and data. Defines three primitives: Tools/Resources/Prompts. JSON-RPC communication. 200+ servers. The USB-C of AI integration. ## Protocol Architecture ### Three Primitives 1. **Tools** — Actions the AI can execute 2. **Resources** — Data the AI can read 3. **Prompts** — Reusable prompt templates ### Transports stdio (local), HTTP+SSE (remote), Streamable HTTP (modern remote). ### SDKs TypeScript, Python, Kotlin, C#. ## FAQ **Q: Claude-only?** A: No — it's an open standard; Cursor, Codex, and more support it. **Q: Can I write it in Python?** A: Yes — the `mcp` package is fully featured. ## Source & Thanks > [modelcontextprotocol/specification](https://github.com/modelcontextprotocol/specification) — MIT --- Source: https://tokrepo.com/en/workflows/anthropic-mcp-specification-protocol-reference-3252f257 Author: Anthropic