Add mcp-stateless module: migrate an MCP server from the 2025 stateful protocol to 2026-07-28 on Spring AI 2.1.0
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4tJPXfq5UyiLSFr49
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
3aa20a1dce
commit
26e0a3875a
@@ -0,0 +1,77 @@
|
||||
# Multi-round-trip request: cancel_order asks for confirmation by returning input_required
|
||||
# PART A: no spring.ai.mcp.server.modern.request-state-secret, so each instance seals with its own random key.
|
||||
|
||||
## A1. first call, no answer yet
|
||||
> POST /mcp (M1)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 200
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":1,"result":{"inputRequests":{"confirm":{"params":{"mode":"form","message":"Cancel order A-101?","requestedSchema":{"type":"object","properties":{"ok":{"type":"boolean"}}}},"method":"elicitation/create"}},"requestState":"<requestState>","resultType":"input_required","_meta":{"io.modelcontextprotocol/serverInfo":{"name":"orders","version":"1.0.0"}}}}
|
||||
|
||||
# The part of requestState before the dot is base64url JSON, readable by anyone who holds it:
|
||||
{"v":1,"s":"orderId=A-101","exp":<epoch-millis>,"m":"tools/call","n":"cancel_order"}
|
||||
|
||||
## A2. retry, answer yes, back on the SAME instance
|
||||
> POST /mcp (M1)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"inputResponses":{"confirm":{"action":"accept","content":{"ok":true}}},"requestState":"<requestState>","_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 200
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"order A-101 cancelled (answered by instance M1)"}],"resultType":"complete","_meta":{"io.modelcontextprotocol/serverInfo":{"name":"orders","version":"1.0.0"}}}}
|
||||
|
||||
## A3. the same retry, but the balancer sends it to the OTHER instance
|
||||
> POST /mcp (M2)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"inputResponses":{"confirm":{"action":"accept","content":{"ok":true}}},"requestState":"<requestState>","_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 400
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Invalid or expired requestState"}}
|
||||
|
||||
## A4. the right instance, but the state was altered in transit
|
||||
> POST /mcp (M1)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"inputResponses":{"confirm":{"action":"accept","content":{"ok":true}}},"requestState":"<requestState>","_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 400
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Invalid or expired requestState"}}
|
||||
|
||||
# PART B: the same secret on every instance (32 bytes or more).
|
||||
|
||||
## B1. first call on M1
|
||||
> POST /mcp (M1)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 200
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":1,"result":{"inputRequests":{"confirm":{"params":{"mode":"form","message":"Cancel order A-101?","requestedSchema":{"type":"object","properties":{"ok":{"type":"boolean"}}}},"method":"elicitation/create"}},"requestState":"<requestState>","resultType":"input_required","_meta":{"io.modelcontextprotocol/serverInfo":{"name":"orders","version":"1.0.0"}}}}
|
||||
|
||||
## B2. retry, answer yes, on M2
|
||||
> POST /mcp (M2)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"inputResponses":{"confirm":{"action":"accept","content":{"ok":true}}},"requestState":"<requestState>","_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 200
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"order A-101 cancelled (answered by instance M2)"}],"resultType":"complete","_meta":{"io.modelcontextprotocol/serverInfo":{"name":"orders","version":"1.0.0"}}}}
|
||||
|
||||
## B3. the user declines, retry on M1
|
||||
> POST /mcp (M1)
|
||||
> MCP-Protocol-Version: 2026-07-28
|
||||
> Mcp-Method: tools/call
|
||||
> Mcp-Name: cancel_order
|
||||
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cancel_order","arguments":{"orderId":"A-101"},"inputResponses":{"confirm":{"action":"decline"}},"requestState":"<requestState>","_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"wire-test","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"elicitation":{"form":{}}}}}}
|
||||
< 200
|
||||
< Content-Type: application/json
|
||||
< {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"order A-101 kept (answered by instance M1)"}],"resultType":"complete","_meta":{"io.modelcontextprotocol/serverInfo":{"name":"orders","version":"1.0.0"}}}}
|
||||
Reference in New Issue
Block a user