> ## Documentation Index
> Fetch the complete documentation index at: https://learn.orbexa.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP — Model Context Protocol

> The standard protocol for connecting AI applications to external tools and data — complete architecture analysis, development guide, and commerce applications

# MCP — Model Context Protocol

> "A USB-C port for AI applications."

## What Is MCP

MCP (Model Context Protocol) is an open standard protocol for connecting AI applications to external systems. It was created by Anthropic, inspired by Microsoft's Language Server Protocol (LSP), and is now managed by the Linux Foundation. MCP follows the same design philosophy as LSP: through a standardized protocol layer, it reduces the N x M integration problem to N + M.

**Official Specification**: [modelcontextprotocol.io](https://modelcontextprotocol.io)

**Specification Repository**: [github.com/modelcontextprotocol/specification](https://github.com/modelcontextprotocol/specification)

**Current Protocol Version**: `2025-11-25`

**In Plain Terms**: USB-C lets your phone connect to chargers, displays, and flash drives. MCP lets AI applications connect to databases, APIs, file systems, and all kinds of tools. One standard interface to connect everything.

## Broad Ecosystem Support

MCP is supported by the following AI applications and development tools:

| Platform                | Role             | Description                   |
| ----------------------- | ---------------- | ----------------------------- |
| **Claude** (Anthropic)  | AI Assistant     | Native MCP connector support  |
| **ChatGPT** (OpenAI)    | AI Assistant     | MCP server connection support |
| **VS Code** (Microsoft) | Development Tool | Copilot supports MCP servers  |
| **Cursor**              | Development Tool | Native MCP support            |
| **Claude Code**         | CLI Tool         | Native MCP support            |

## MCP Architecture

### Three Participants

MCP is a **stateful protocol** using a client-server architecture with three core participants:

| Participant    | Role                                                                       | Examples                              |
| -------------- | -------------------------------------------------------------------------- | ------------------------------------- |
| **MCP Host**   | AI application that manages one or more MCP clients                        | Claude Desktop, VS Code, ChatGPT      |
| **MCP Client** | Internal component of the Host, maintains a 1:1 connection with one Server | Automatically created within the Host |
| **MCP Server** | Provides tools, data, and prompts to clients                               | Services you develop                  |

### Two-Layer Architecture

| Layer               | Responsibility                                                                                                 | Protocols and Technologies                 |
| ------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| **Data Layer**      | Defines message structure and semantics (lifecycle, tools, resources, prompts, sampling, elicitation, logging) | JSON-RPC 2.0                               |
| **Transport Layer** | Defines communication channels and authentication                                                              | stdio / Streamable HTTP / Custom transport |

### Transport Methods

| Transport           | Description                                                                                                       | Use Case                                         |
| ------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| **stdio**           | Server runs as a child process, communicating via stdin/stdout with newline-delimited messages                    | Local process, zero network overhead             |
| **Streamable HTTP** | Single MCP endpoint; POST sends requests, GET subscribes to SSE streams. `Mcp-Session-Id` header manages sessions | Remote servers with OAuth authentication support |

## MCP Core Capabilities (Primitives)

### Server-Side Primitives

**1. Tools** — Model-Controlled

Executable functions that AI models autonomously decide when to invoke. Discovered via `tools/list`, executed via `tools/call`. Supports `inputSchema` for defining input parameters, and optional `outputSchema` for defining structured output.

```json theme={null}
{
  "name": "weather_current",
  "description": "Get current weather for any city",
  "inputSchema": {
    "type": "object",
    "properties": {
      "location": { "type": "string", "description": "City name" }
    },
    "required": ["location"]
  }
}
```

**2. Resources** — Application-Controlled

Data sources that provide context to AI applications, identified by URIs (supporting RFC 6570 URI templates). Discovered via `resources/list`, read via `resources/read`, with subscription support via `resources/subscribe`. Resources carry Annotations (audience, priority, lastModified, and other metadata).

**3. Prompts** — User-Controlled

Reusable interaction templates. Discovered via `prompts/list`, retrieved via `prompts/get` (with parameterized arguments).

### Client-Side Primitives

| Primitive       | Purpose                                     | Method                                |
| --------------- | ------------------------------------------- | ------------------------------------- |
| **Sampling**    | Server requests LLM inference from the Host | `sampling/createMessage`              |
| **Roots**       | Informs the Server of filesystem boundaries | `roots/list` (returns `file://` URIs) |
| **Elicitation** | Server requests information from the user   | `elicitation/request`                 |

### Content Types

MCP supports five content types, all of which can carry Annotations:

| Type                | Description             |
| ------------------- | ----------------------- |
| `text`              | Text content            |
| `image`             | Images (Base64 or URI)  |
| `audio`             | Audio content           |
| `resource_link`     | Resource link reference |
| `embedded_resource` | Embedded resource       |

## MCP in Commerce Applications

| Scenario              | Tools Provided by MCP Server       | Effect                                                      |
| --------------------- | ---------------------------------- | ----------------------------------------------------------- |
| **Product Search**    | `search_products(query, category)` | AI agents can search your product catalog                   |
| **Inventory Query**   | `check_inventory(sku)`             | AI agents can check real-time inventory                     |
| **Order Status**      | `get_order_status(order_id)`       | Customers can check order progress via AI                   |
| **Return Processing** | `create_return(order_id, reason)`  | AI agents can initiate returns for customers                |
| **Price Inquiry**     | `get_price(sku, quantity)`         | AI agents get real-time quotes (including volume discounts) |
| **Trust Query**       | `otr_verify(domain)`               | AI agents query merchant trust scores                       |

## MCP Server Development Workflow

### 1. Define Tools

Determine which tools your MCP Server will expose. Each tool needs:

* A name and description (the description directly influences the AI model's selection decisions)
* Input parameter JSON Schema (`inputSchema`)
* Optional output Schema (`outputSchema`, defining structured return format)
* Execution logic

### 2. Choose an SDK

MCP provides multi-language SDKs:

* **TypeScript/JavaScript**: `@modelcontextprotocol/sdk`
* **Python**: `mcp`
* **Other languages**: Implement via JSON-RPC 2.0 directly

### 3. Implement the Server

```typescript theme={null}
// TypeScript MCP Server example scaffold
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

const server = new McpServer({
  name: "my-commerce-server",
  version: "1.0.0"
});

// Define a tool
server.tool(
  "search_products",
  "Search the product catalog",
  { query: { type: "string" }, category: { type: "string" } },
  async ({ query, category }) => {
    // Call your product database or API
    const results = await searchProducts(query, category);
    return { content: [{ type: "text", text: JSON.stringify(results) }] };
  }
);

// Start the server
server.start();
```

### 4. Deploy

* **Local Server**: Use stdio transport, runs on the user's machine
* **Remote Server**: Use Streamable HTTP transport, deployed on your server

### 5. User Connection

Users add your Server connection information in MCP-enabled applications such as Claude, ChatGPT, or VS Code to start using it.

## Protocol Lifecycle

An MCP connection has three phases:

```
1. Initialization
   -> Client sends initialize request, negotiating protocol version and capabilities
   -> Server responds with supported capabilities
   -> Client sends initialized notification to confirm

2. Operation
   -> Client requests tools/list to get available tools
   -> Client calls tools/call to execute specific tools
   -> Server pushes notifications such as tool list changes
   -> Server can request LLM inference via Sampling
   -> Server can request user input via Elicitation

3. Shutdown
   -> Connection terminates, resources are cleaned up
```

## Table of Contents

1. [MCP Core Concepts](/en/book-5/ch1-core-concepts) — Architecture details, participant roles, protocol lifecycle
2. [Data Layer Protocol](/en/book-5/ch2-data-layer) — JSON-RPC 2.0 message format, capability negotiation
3. [Transport Layer](/en/book-5/ch3-transport) — stdio vs Streamable HTTP, OAuth 2.1 authentication
4. [Building an MCP Server](/en/book-5/ch4-build-server) — Complete TypeScript/Python development guide
5. [Commerce MCP Server](/en/book-5/ch5-commerce-server) — MCP Server design patterns for e-commerce
6. [Resources and Prompts](/en/book-5/ch6-resources-prompts) — Working with Resources and Prompts
7. [Security and Authentication](/en/book-5/ch7-security) — OAuth 2.1 integration, PKCE, permission management
8. [Testing and Debugging](/en/book-5/ch8-testing) — MCP Inspector usage guide
9. [Deployment Guide](/en/book-5/ch9-deployment) — Local deployment vs remote deployment
10. [Case Studies](/en/book-5/ch10-case-studies) — MCP Server implementations for different scenarios

### AI Prompt: Build a Commerce MCP Server

```
Help me build a commerce MCP Server.

Preparation:
1. Read the MCP official documentation: https://modelcontextprotocol.io
2. Pay special attention to: /docs/develop/build-server

My requirements:
- Purpose: [product search / inventory query / order management / customer service / other]
- Tech stack: [TypeScript / Python / other]
- Data source: [database / API / files]
- Deployment: [local / remote]

Please output:
1. MCP Server tool design (name, description, input/output for each tool)
2. Complete runnable code
3. Configuration file (connection config for Claude Desktop or other clients)
4. Testing methods
5. Deployment steps
```

<Note>
  MCP is an actively evolving protocol with ongoing specification updates. This book is based on the official documentation as of April 2026 (protocol version `2025-11-25`). Always refer to the latest version at [modelcontextprotocol.io](https://modelcontextprotocol.io).
</Note>
