Skip to content

Commit a12f14c

Browse files
committed
examples: rewrite default examples for 2026 stateless
Replace the stateful 2025-11-25 handshake prose (initialize -> notifications/initialized -> Mcp-Session-Id) in the 2026-default examples with the stateless 2026 flow: server/discover plus per-request _meta carrying the three io.modelcontextprotocol/* keys, MCP-Protocol-Version: 2026-07-28, no session header. Covers READMEs, doc-comments, banners, curl snippets, the middleware-auth-lambda test-event fixtures and TESTING.md, the icon-showcase label, and a tool-output-introspection rustdoc fix. Genuine 2025 snippets are kept under explicit "2025-11-25 (opt-in)" labels.
1 parent dad4136 commit a12f14c

21 files changed

Lines changed: 176 additions & 68 deletions

File tree

examples/derive-macro-server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This example demonstrates how to use the `#[derive(McpTool)]` macro for simplifi
1010
- **Optional Parameters**: Handling optional fields with `Option<T>`
1111
- **Error Handling**: Proper error handling in tool implementations
1212
- **Complex Data Types**: Working with various parameter types (strings, numbers, booleans)
13-
- **MCP 2025-11-25 Compliance**: Full specification compliance with proper `_meta` field handling
13+
- **MCP 2026-07-28 Compliance**: Full specification compliance with proper `_meta` field handling
1414

1515
## 🛠️ Available Tools
1616

examples/function-macro-server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Each tool defines its JSON schema with:
245245
- Manual trait implementations (this example)
246246
- Derive macros for struct-based tools (`#[derive(McpTool)]`)
247247
- Enhanced declarative `tool!` macro with parameter constraints
248-
- Full MCP 2025-11-25 protocol support with real-time notifications
248+
- Full MCP 2026-07-28 protocol support with real-time notifications
249249

250250
**What's Coming:**
251251
- `#[mcp_tool]` function attribute macro completion

examples/icon-showcase/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors.workspace = true
66
license.workspace = true
77
repository.workspace = true
88
homepage.workspace = true
9-
description = "Example showcasing MCP 2025-11-25 icon support on tools, resources, prompts, and implementations"
9+
description = "Example showcasing MCP 2026-07-28 icon support on tools, resources, prompts, and implementations"
1010

1111
[dependencies]
1212
turul-mcp-protocol = { workspace = true }

examples/icon-showcase/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! MCP 2025-11-25 Icon Support Showcase
1+
//! MCP 2026-07-28 Icon Support Showcase
22
//!
33
//! Demonstrates the `icons` field available on Tool, Resource, Prompt,
44
//! ResourceTemplate, and Implementation types. Icons use the `Icon` struct
@@ -11,7 +11,7 @@ use turul_mcp_protocol::{
1111
};
1212

1313
fn main() {
14-
println!("=== MCP 2025-11-25 Icon Support Showcase ===\n");
14+
println!("=== MCP 2026-07-28 Icon Support Showcase ===\n");
1515

1616
// --- Tool with an HTTPS icon ---
1717
let calculator_tool = Tool::new(

examples/middleware-auth-lambda/TESTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,18 @@ cargo lambda invoke middleware-auth-lambda \
120120
--output-format json | jq .
121121
```
122122

123+
The event body is a stateless 2026-07-28 `server/discover` request — no
124+
`initialize` handshake, no `Mcp-Session-Id`, and the per-request `_meta`
125+
(protocolVersion, clientInfo, clientCapabilities) inside `params`.
126+
123127
**Expected response**:
124128
```json
125129
{
126130
"jsonrpc": "2.0",
127131
"id": 1,
128132
"result": {
129-
"protocolVersion": "2025-11-25",
133+
"resultType": "complete",
134+
"supportedVersions": ["2026-07-28"],
130135
"capabilities": {},
131136
"serverInfo": {
132137
"name": "middleware-auth-lambda",
@@ -284,7 +289,7 @@ cat /tmp/lambda-output.log | grep "Authorizer context"
284289

285290
## Streamable HTTP Compatibility
286291

287-
This example uses the MCP 2025-11-25 **Streamable HTTP** transport via REST API (V1). REST API supports standard HTTP POST with full request/response control, making it compatible with Streamable HTTP. The Lambda adapter converts the API Gateway event into a standard `hyper::Request`, which the framework's `StreamableHttpHandler` processes normally.
292+
This example uses the MCP 2026-07-28 **Streamable HTTP** transport via REST API (V1). REST API supports standard HTTP POST with full request/response control, making it compatible with Streamable HTTP. The Lambda adapter converts the API Gateway event into a standard `hyper::Request`, which the framework's `StreamableHttpHandler` processes normally. The 2026 core is stateless: each request carries its own `_meta`; there is no `initialize`/`notifications/initialized` handshake and no `Mcp-Session-Id`.
288293

289294
**Note**: All three authorizer context shapes (V1 nested, V1 flat, V2) are supported for extraction. However, Streamable HTTP transport requires REST API (V1).
290295

examples/middleware-auth-lambda/src/main.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
//!
1818
//! # Transport: Streamable HTTP (REST API V1)
1919
//!
20-
//! This example uses the MCP 2025-11-25 Streamable HTTP transport via REST API (V1).
20+
//! This example uses the MCP 2026-07-28 Streamable HTTP transport via REST API (V1).
2121
//! REST API supports standard HTTP POST with full request/response control, making it
2222
//! compatible with Streamable HTTP. The Lambda adapter converts the API Gateway event
2323
//! into a standard `hyper::Request`, which the framework's `StreamableHttpHandler`
24-
//! processes normally.
24+
//! processes normally. The 2026 core is stateless: there is no `initialize`/
25+
//! `notifications/initialized` handshake and no `Mcp-Session-Id` — every request
26+
//! carries its own `_meta` (protocolVersion, clientInfo, clientCapabilities).
2527
//!
2628
//! **Note**: HTTP API (V2) authorizer context extraction is fully supported, but
2729
//! Streamable HTTP transport requires REST API (V1).
@@ -91,18 +93,21 @@
9193
//! # Usage
9294
//!
9395
//! ```bash
94-
//! # With valid API key
96+
//! # With valid API key (2026-07-28 stateless: no session handshake;
97+
//! # each request carries its own `_meta`)
9598
//! curl -X POST http://localhost:9000/lambda-url/middleware-auth-lambda \
9699
//! -H "Content-Type: application/json" \
97100
//! -H "Accept: application/json" \
101+
//! -H "MCP-Protocol-Version: 2026-07-28" \
98102
//! -H "X-API-Key: secret-key-123" \
99-
//! -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
103+
//! -d '{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"test","version":"1.0"},"io.modelcontextprotocol/clientCapabilities":{}}}}'
100104
//!
101-
//! # Without API key (should fail)
105+
//! # Without API key (should fail at the auth layer)
102106
//! curl -X POST http://localhost:9000/lambda-url/middleware-auth-lambda \
103107
//! -H "Content-Type: application/json" \
104108
//! -H "Accept: application/json" \
105-
//! -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
109+
//! -H "MCP-Protocol-Version: 2026-07-28" \
110+
//! -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"test","version":"1.0"},"io.modelcontextprotocol/clientCapabilities":{}}}}'
106111
//! ```
107112
108113
use async_trait::async_trait;
@@ -291,7 +296,7 @@ async fn main() -> Result<(), Error> {
291296
init_logging();
292297

293298
info!("🚀 Starting AWS Lambda MCP Server with Authentication Middleware");
294-
info!("Architecture: MCP 2025-11-25 with middleware auth layer");
299+
info!("Architecture: MCP 2026-07-28 (stateless) with middleware auth layer");
295300
info!(" - X-API-Key header validation");
296301
info!(" - Lambda authorizer context extraction");
297302
info!(" - User context injection");

examples/middleware-auth-lambda/test-events/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ Examples:
100100

101101
## Transport
102102

103-
This example uses MCP 2025-11-25 **Streamable HTTP** transport via REST API (V1). REST API supports standard HTTP POST with full request/response control, making it compatible with Streamable HTTP.
103+
This example uses MCP 2026-07-28 **Streamable HTTP** transport via REST API (V1). REST API supports standard HTTP POST with full request/response control, making it compatible with Streamable HTTP. The 2026 core is stateless: each request carries its own `_meta` (protocolVersion, clientInfo, clientCapabilities); there is no `initialize`/`notifications/initialized` handshake and no `Mcp-Session-Id`.
104104

105105
**Note**: All three authorizer shapes (V1 nested, V1 flat, V2) are supported for context extraction. However, Streamable HTTP transport requires REST API (V1).

examples/middleware-auth-lambda/test-events/apigw-v1-flat-authorizer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"headers": {
66
"Content-Type": "application/json",
77
"Accept": "application/json",
8+
"MCP-Protocol-Version": "2026-07-28",
89
"X-API-Key": "secret-key-123"
910
},
10-
"body": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-11-25\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"}}}",
11+
"body": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"server/discover\",\"params\":{\"_meta\":{\"io.modelcontextprotocol/protocolVersion\":\"2026-07-28\",\"io.modelcontextprotocol/clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"},\"io.modelcontextprotocol/clientCapabilities\":{}}}}",
1112
"requestContext": {
1213
"accountId": "123456789012",
1314
"apiId": "test-api-id",

examples/middleware-auth-lambda/test-events/apigw-v1-with-authorizer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"headers": {
66
"Content-Type": "application/json",
77
"Accept": "application/json",
8+
"MCP-Protocol-Version": "2026-07-28",
89
"X-API-Key": "secret-key-123"
910
},
10-
"body": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-11-25\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"}}}",
11+
"body": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"server/discover\",\"params\":{\"_meta\":{\"io.modelcontextprotocol/protocolVersion\":\"2026-07-28\",\"io.modelcontextprotocol/clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"},\"io.modelcontextprotocol/clientCapabilities\":{}}}}",
1112
"requestContext": {
1213
"accountId": "123456789012",
1314
"apiId": "test-api-id",

examples/middleware-auth-lambda/test-events/apigw-v2-with-authorizer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"headers": {
77
"content-type": "application/json",
88
"accept": "application/json",
9+
"mcp-protocol-version": "2026-07-28",
910
"x-api-key": "secret-key-123"
1011
},
1112
"requestContext": {
@@ -31,6 +32,6 @@
3132
"time": "01/Jan/2025:00:00:00 +0000",
3233
"timeEpoch": 1704067200000
3334
},
34-
"body": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-11-25\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"}}}",
35+
"body": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"server/discover\",\"params\":{\"_meta\":{\"io.modelcontextprotocol/protocolVersion\":\"2026-07-28\",\"io.modelcontextprotocol/clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"},\"io.modelcontextprotocol/clientCapabilities\":{}}}}",
3536
"isBase64Encoded": false
3637
}

0 commit comments

Comments
 (0)