### Project directory root example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of a project directory root with a file:// URI and an optional name. ```json { "uri": "file:///home/user/projects/myproject", "name": "My Project" } ``` -------------------------------- ### Example Discover request Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example JSON-RPC request for server/discover. Includes protocol version, client info, and client capabilities in the _meta field. ```json { “jsonrpc”: “2.0”, “id”: “discover-1”, “method”: “server/discover”, “params”: { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} } } } ``` -------------------------------- ### Multiple root directories example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example response with multiple root directories, each with a file:// URI and an optional name. ```json { "roots": [ { "uri": "file:///home/user/repos/frontend", "name": "Frontend Repository" }, { "uri": "file:///home/user/repos/backend", "name": "Backend Repository" } ] } ``` -------------------------------- ### List resources request example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example request for listing resources. Includes protocol version, client info, and capabilities in the metadata. ```json { “jsonrpc”: “2.0”, “id”: “list-resources-example”, “method”: “resources/list”, “params”: { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} } } } ``` -------------------------------- ### Example prompts/list request Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example JSON-RPC request for listing prompts. Includes protocol version, client info, and capabilities in the _meta field. ```json { “jsonrpc”: “2.0”, “id”: “list-prompts-example”, “method”: “prompts/list”, “params”: { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} } } } ``` -------------------------------- ### Single root directory example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example response with a single root directory. The root has a file:// URI and an optional name. ```json { "roots": [ { "uri": "file:///home/user/projects/myproject", "name": "My Project" } ] } ``` -------------------------------- ### Resource with Annotations Example Source: https://modelcontextprotocol.io/specification/2026-07-28/server/resources Example resource with annotations. The `annotations` object includes `audience`, `priority`, and `lastModified` fields. ```json { "uri": "file:///project/README.md", "name": "README.md", "title": "Project Documentation", "mimeType": "text/markdown", "annotations": { "audience": ["user"], "priority": 0.8, "lastModified": "2025-01-12T15:00:58Z" } } ``` -------------------------------- ### Binary Content Resource Example Source: https://modelcontextprotocol.io/specification/2026-07-28/server/resources Example of a resource with binary content. The `blob` field holds base64-encoded data. ```json { "uri": "file:///example.png", "mimeType": "image/png", "blob": "base64-encoded-data" } ``` -------------------------------- ### Text Content Resource Example Source: https://modelcontextprotocol.io/specification/2026-07-28/server/resources Example of a resource with text content. The `text` field holds the resource data. ```json { "uri": "file:///example.txt", "mimeType": "text/plain", "text": "Resource content" } ``` -------------------------------- ### Tool call params with progress token example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example params object for a build_simulation tool call that includes a progressToken in _meta for progress tracking. ```json { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {}, “progressToken”: “oivaizmir” }, “name”: “build_simulation”, “arguments”: { “city”: “Micropolis” } } ``` -------------------------------- ### List roots request example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example JSON-RPC request for listing roots. The method is "roots/list" and the id is "list-roots-example". ```json { "id": "list-roots-example", "method": "roots/list" } ``` -------------------------------- ### Single completion value example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example result with a single completion value “flask”. total is 1 and hasMore is false. ```json { “resultType”: “complete”, “completion”: { “values”: [“flask”], “total”: 1, “hasMore”: false } } ``` -------------------------------- ### Example Discover result response Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example JSON-RPC response for a server/discover request. Shows a complete result with supported versions, capabilities, server info, TTL, and cache scope. ```json { “jsonrpc”: “2.0”, “id”: “discover-1”, “result”: { “resultType”: “complete”, “supportedVersions”: [“2026-07-28”], “capabilities”: { “tools”: {}, “resources”: {} }, “_meta”: { “io.modelcontextprotocol/serverInfo”: { “name”: “ExampleServer”, “version”: “1.0.0” } }, “ttlMs”: 3600000, “cacheScope”: “public” } } ``` -------------------------------- ### get_weather tool call params example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example params object for a get_weather tool call, showing the required _meta and name fields with an arguments map. ```json { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} }, “name”: “get_weather”, “arguments”: { “location”: “New York” } } ``` -------------------------------- ### Multiple completion values with more available example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example result with multiple completion values and more available. values contains three items, total is 10, and hasMore is true. ```json { “resultType”: “complete”, “completion”: { “values”: [“python”, “pytorch”, “pyside”], “total”: 10, “hasMore”: true } } ``` -------------------------------- ### Example Request with Bearer Token Source: https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization Example HTTP request showing the Authorization header with a bearer token. The token is an example JWT. ```http GET /mcp HTTP/1.1 Host: mcp.example.com Authorization: Bearer eyJhbGciOiJIUzI1NiIs... ``` -------------------------------- ### Explicit dialect (draft-07) JSON Schema example Source: https://modelcontextprotocol.io/specification/2026-07-28/basic Example of a JSON Schema with an explicit $schema field specifying draft-07. This schema defines the same object structure as the default dialect example but explicitly declares the dialect. ```json { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer", "minimum": 0 } }, "required": ["name"] } ``` -------------------------------- ### SamplingMessage example: single content block Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of a SamplingMessage with a single text content block. ```json { “role”: “user”, “content”: { “type”: “text”, “text”: “What is the capital of France?” } } ``` -------------------------------- ### SamplingMessage example: multiple content blocks Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of a SamplingMessage with multiple content blocks, each containing a tool result. ```json { “role”: “user”, “content”: [ { “type”: “tool_result”, “toolUseId”: “call_123”, “content”: [{ “type”: “text”, “text”: “Result 1” }] }, { “type”: “tool_result”, “toolUseId”: “call_456”, “content”: [{ “type”: “text”, “text”: “Result 2” }] } ] } ``` -------------------------------- ### Model Preferences Example Source: https://modelcontextprotocol.io/specification/2026-07-28/client/sampling Shows how a server expresses model preferences using hints and capability priorities. Hints are substrings evaluated in order, and clients may map them to equivalent models from other providers. ```json { "hints": [ { "name": "claude-3-sonnet" }, // Prefer Sonnet-class models { "name": "claude" } // Fall back to any Claude model ], "costPriority": 0.3, // Cost is less important "speedPriority": 0.8, // Speed is very important "intelligencePriority": 0.5 // Moderate capability needs } ``` -------------------------------- ### Root object for a project directory Source: https://modelcontextprotocol.io/specification/2026-07-28/client Example root object for a project directory. The uri must be a file:// URI. ```json { "uri": "file:///home/user/projects/myproject", "name": "My Project" } ``` -------------------------------- ### List resource templates request example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example JSON-RPC request to list resource templates. It includes the protocol version, client info, and empty client capabilities in the _meta object. ```json { “jsonrpc”: “2.0”, “id”: “list-resource-templates-example”, “method”: “resources/templates/list”, “params”: { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} } } } ``` -------------------------------- ### subscriptions/listen request example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example request for the subscriptions/listen method. The client opens a long-lived channel and opts in to toolsListChanged and resourceSubscriptions notifications. The server MUST NOT send notification types not explicitly requested. ```json { "jsonrpc": "2.0", "id": "listen-1", "method": "subscriptions/listen", "params": { "_meta": { "io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientInfo": { "name": "ExampleClient", "version": "1.0.0" }, "io.modelcontextprotocol/clientCapabilities": {} }, "notifications": { "toolsListChanged": true, "resourceSubscriptions": ["file:///project/config.json"] } } } ``` -------------------------------- ### OpenTelemetry trace context in _meta (JSON-RPC example) Source: https://modelcontextprotocol.io/specification/2026-07-28/basic Non-normative example showing trace context propagation in a JSON-RPC request's _meta field. The example includes a tools/call request with a traceparent value following W3C Trace Context format. ```json { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "get_weather", "arguments": { "location": "New York" }, "_meta": { "traceparent": "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01" } } } ``` -------------------------------- ### Resource templates list with cursor and TTL example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example result object for a resources/templates/list response. Includes a nextCursor for pagination, a TTL of 3600000 ms, and a public cache scope. ```json { “resultType”: “complete”, “resourceTemplates”: [ { “uriTemplate”: “file:///{path}”, “name”: “Project Files”, “title”: ”📁 Project Files”, “description”: “Access files in the project directory”, “mimeType”: “application/octet-stream”, “icons”: [ { “src”: “https://example.com/folder-icon.png”, “mimeType”: “image/png”, “sizes”: [“48x48”] } ] } ], “nextCursor”: “next-page-cursor”, “ttlMs”: 3600000, “cacheScope”: “public” } ``` -------------------------------- ### File resource with annotations Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of a file resource with annotations. Shows how to set the `uri`, `name`, `title`, `mimeType`, and `annotations` fields. ```json { “uri”: “file:///project/README.md”, “name”: “README.md”, “title”: “Project Documentation”, “mimeType”: “text/markdown”, “annotations”: { “audience”: [“user”], “priority”: 0.8, “lastModified”: “2025-01-12T15:00:58Z” } } ``` -------------------------------- ### Roots array for multiple repositories Source: https://modelcontextprotocol.io/specification/2026-07-28/client Example roots array for multiple repositories. ```json [ { "uri": "file:///home/user/repos/frontend", "name": "Frontend Repository" }, { "uri": "file:///home/user/repos/backend", "name": "Backend Repository" } ] ``` -------------------------------- ### List resource templates result response example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example JSON response for a resources/templates/list request. Shows a complete result with a single resource template, a TTL of 3600000 ms, and a public cache scope. ```json { “jsonrpc”: “2.0”, “id”: “list-resource-templates-example”, “result”: { “resultType”: “complete”, “resourceTemplates”: [ { “uriTemplate”: “file:///{path}”, “name”: “Project Files”, “title”: “Project Files”, “description”: “Access files in the project directory”, “mimeType”: “application/octet-stream”, “icons”: [ { “src”: “https://example.com/folder-icon.png”, “mimeType”: “image/png”, “sizes”: [“48x48”] } ] } ], “ttlMs”: 3600000, “cacheScope”: “public” } } ``` -------------------------------- ### ResourceUpdatedNotificationParams interface and example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Defines the ResourceUpdatedNotificationParams interface and shows an example params object. The uri may be a sub-resource of the one the client subscribed to. ```typescript interface ResourceUpdatedNotificationParams { _meta?: NotificationMetaObject; uri: string; } ``` ```json { "uri": "file:///project/src/main.rs" } ``` -------------------------------- ### Example: Log database connection failed (notifications/message) Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example notification for a failed database connection. Deprecated as of protocol version 2026-07-28 (SEP-2577). ```json { “jsonrpc”: “2.0”, “method”: “notifications/message”, “params”: { “level”: “error”, “logger”: “database”, “data”: { “error”: “Connection failed”, “details”: { “host”: “localhost”, “port”: 5432 } } } } ``` -------------------------------- ### CancelledNotificationParams example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of the params object for a notifications/cancelled notification. The requestId is required and must correspond to a previously issued request; reason is optional. ```json { "requestId": "123", "reason": "User requested cancellation" } ``` -------------------------------- ### Client ID Metadata Document Example Source: https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration Example metadata document that must be hosted at an HTTPS URL and include at least client_id, client_name, and redirect_uris. The client_id value must match the document URL exactly. ```json { "client_id": "https://app.example.com/oauth/client-metadata.json", "client_name": "Example MCP Client", "client_uri": "https://app.example.com", "logo_uri": "https://app.example.com/logo.png", "redirect_uris": [ "http://127.0.0.1:3000/callback", "http://localhost:3000/callback" ], "grant_types": ["authorization_code"], "response_types": ["code"], "token_endpoint_auth_method": "none" } ``` -------------------------------- ### Sampling request example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Shows a complete sampling request with method, params, messages, model preferences, system prompt, and max tokens. This is the full request structure sent from the server to the client. ```json { "method": "sampling/createMessage", "params": { "messages": [ { "role": "user", "content": { "type": "text", "text": "What is the capital of France?" } } ], "modelPreferences": { "hints": [ { "name": "claude-3-sonnet" } ], "intelligencePriority": 0.8, "speedPriority": 0.5 }, "systemPrompt": "You are a helpful assistant.", "maxTokens": 100 } } ``` -------------------------------- ### Prompt argument completion with context example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example params object for a prompt argument completion with context. It includes previously-resolved variables (language: python) to help complete the “framework” argument. ```json { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} }, “ref”: { “type”: “ref/prompt”, “name”: “code_review” }, “argument”: { “name”: “framework”, “value”: “fla” }, “context”: { “arguments”: { “language”: “python” } } } ``` -------------------------------- ### InputRequests example with elicitation and sampling requests Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of an InputRequests map with two server-initiated requests: an elicitation/create form request for a GitHub username and a sampling/createMessage request asking for the capital of France. Keys are server-assigned identifiers; values are the request objects. ```json { “github_login”: { “method”: “elicitation/create”, “params”: { “mode”: “form”, “message”: “Please provide your GitHub username”, “requestedSchema”: { “type”: “object”, “properties”: { “name”: { “type”: “string” } }, “required”: [“name”] } } }, “capital_of_france”: { “method”: “sampling/createMessage”, “params”: { “messages”: [ { “role”: “user”, “content”: { “type”: “text”, “text”: “What is the capital of France?” } } ], “maxTokens”: 100 } } } ``` -------------------------------- ### Progress message params example Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of the params object for a progress notification. It includes the progressToken, progress, total, and message fields as defined in ProgressNotificationParams. ```json { “progressToken”: “oivaizmir”, “progress”: 50, “total”: 100, “message”: “Reticulating splines…” } ``` -------------------------------- ### Read resource request Source: https://modelcontextprotocol.io/specification/2026-07-28/schema Example of a `resources/read` request. The `params` include `_meta` with protocol version and client info, and the `uri` of the resource to read. ```json { “jsonrpc”: “2.0”, “id”: “read-resource-example”, “method”: “resources/read”, “params”: { “_meta”: { “io.modelcontextprotocol/protocolVersion”: “2026-07-28”, “io.modelcontextprotocol/clientInfo”: { “name”: “ExampleClient”, “version”: “1.0.0” }, “io.modelcontextprotocol/clientCapabilities”: {} }, “uri”: “file:///project/src/main.rs” } } ```