Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 6 min read

A confirmation with no session

What a sealed requestState can and can't promise on MCP 2026-07-28 Some tools should ask before they act: delete, pay, send. On MCP's 2026-07-28 protocol a server can pause a tool call and ask the user, in the middle of

A confirmation with no session

What a sealed requestState can and can't promise on MCP 2026-07-28

Some tools should ask before they act: delete, pay, send. On MCP's 2026-07-28 protocol a server can pause a tool call and ask the user, in the middle of the call, without holding a connection open. The catch is that the server keeps no session. Whatever it needs to remember between the question and the answer has to travel with the client, in a token called requestState.

mcp-better teaches this pattern: it is a Rust MCP server written as a textbook. Its confirm_echo tool asks you to type CONFIRM, then echoes your message. A raw HTTP test of version 0.7.0 found that the confirmation promised more than it delivered. Version 0.8.0 adds an expiry and refuses a changed message, and says plainly what it still doesn't do. Every response below is a real capture from those two versions.

1. Two round trips, no session

This is SEP-2322, multi round-trip requests. Round 1 is an ordinary tool call:

round 1 Β· request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "confirm_echo",
    "arguments": {
      "message": "confirm me"
    },
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientCapabilities": {
        "elicitation": {
          "form": {}
        }
      }
    }
  }
}

The server doesn't run the tool. It answers input_required, says what it needs (a form asking for CONFIRM), and hands back a sealed token:

round 1 Β· response (mcp-better 0.8.0, schema trimmed)

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "resultType": "input_required",
    "inputRequests": {
      "confirm": {
        "method": "elicitation/create",
        "params": {
          "message": "Type CONFIRM to echo the sealed message.",
          "mode": "form",
          "requestedSchema": "…"
        }
      }
    },
    "requestState": "rs1.AAABohveDBN7…DwylF-M"
  }
}

The client shows the form, then sends the same call again with the answer and the same token:

round 2 Β· request

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "confirm_echo",
    "arguments": {
      "message": "confirm me"
    },
    "requestState": "rs1.AAABohveDBN7…DwylF-M",
    "inputResponses": {
      "confirm": {
        "action": "accept",
        "content": {
          "confirm": "CONFIRM"
        }
      }
    },
    "_meta": "…"
  }
}

round 2 Β· response

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "resultType": "complete",
    "content": [
      {
        "type": "text",
        "text": "{\"confirmed\":true,\"echo\":\"confirm me\",…}"
      }
    ],
    "isError": false
  }
}

Two round trips, no session: everything round 2 needs travels in the token.
Two round trips, no session: everything round 2 needs travels in the token.

WHY: the server can't trust anything in round 2 that it didn't seal in round 1. The client could send back anything.

2. Signed, not secret

mcp-better seals the token with rmcp's RequestStateCodec: an HMAC-SHA256 tag over the payload. Change one byte and round 2 fails:

{
  "jsonrpc": "2.0",
  "id": 5,
  "error": {
    "code": -32602,
    "message": "requestState failed integrity check or expired (start again)"
  }
}

But look inside the token. A client must not; an attacker will. The middle part is base64url, and it decodes to plain JSON:

# 0.8.0's token, split at its dots
rs1
.AAABohveDBN7Im1lc3NhZ2UiOiJjb25maXJtIG1lIn0
.sEgJTcgy3dI6341xIRsGjf7IIuu-hxPkkoDbDwylF-M

# the middle part, decoded
[8-byte expiry] {"message":"confirm me"}

What a sealed requestState is. Signed, not secret.
What a sealed requestState is. Signed, not secret.

NOTE: rmcp's docs say it: β€œValues are authenticated, not encrypted; key ids and payloads remain readable.” Never put private data in it, or encrypt it.

3. Give it an expiry

In 0.7.0 the first 8 bytes of the payload were all zero: no expiry. Nothing marked a token as used either, because there's no session to mark. So one round-1 token completed round 2 again and again. Here it is, the same token sent twice to 0.7.0:

first use

{
  "confirmed": true,
  "echo": "confirm me",
  "mrtr": "confirm_echo",
  "resultType": "complete"
}

same token again

{
  "confirmed": true,
  "echo": "confirm me",
  "mrtr": "confirm_echo",
  "resultType": "complete"
}

rmcp can stamp an expiry into the token, and opening it after that fails. 0.8.0 seals every round-1 token with five minutes:

src/server.rs Β· mcp-better 0.8.0

let sealed = self
    .state_codec
    .seal_json_with(
        &ConfirmState { message: message.clone() },
        &SealOptions::new()
            .associated_data(MRTR_AAD)
            .ttl(self.confirm_ttl),
    )
    .map_err(|e| { /* … */ })?;

After five minutes, round 2 is refused:

round 2 Β· a round-1 token, 305 seconds later

{
  "jsonrpc": "2.0",
  "id": 2,
  "error": {
    "code": -32602,
    "message": "requestState failed integrity check or expired (start again)"
  }
}

A test that doesn't wait five minutes: build the server with a 1 ms lifetime, sleep 20 ms, expect the error.

#[test]
fn confirm_echo_rejects_expired_state() {
    let server = BetterServer::new()
        .with_confirm_ttl(std::time::Duration::from_millis(1));
    let sealed = round1_state(&server, "late");
    std::thread::sleep(std::time::Duration::from_millis(20));
    let req = confirm_args("late")
        .with_input_responses(accepted())
        .with_request_state(sealed);
    let err = server.confirm_echo_call(req, &elicit_caps()).unwrap_err();
    assert_eq!(err.code, ErrorCode::INVALID_PARAMS);
}

4. Say what's left

An expiry bounds replay. It doesn't stop it. Inside the five minutes, 0.8.0 still accepts the same token twice:

{
  "confirmed": true,
  "echo": "confirm me",
  "mrtr": "confirm_echo",
  "resultType": "complete"
}

What an expiry buys, and what it doesn't.
What an expiry buys, and what it doesn't.

For an echo, that's harmless. For a tool with real effects, it isn't: put a nonce in the sealed state and keep a set of used nonces on the server, at least until they expire. That is state, and keeping it is a choice 2026-07-28 makes you take on purpose. mcp-better doesn't, and its docs say so.

GOTCHA: The spec says servers SHOULD seal three things into the state: the authenticated user, a short expiry, and the method plus a digest of its parameters. rmcp's associated data can carry the first and the last. mcp-better 0.8.0 has the expiry and binds only the tool name. A real server should bind the user and a digest of the call, so a token can't be replayed by someone else or against a different call.

5. Refuse changed arguments

Round 2 carries the arguments again. What if they changed? In 0.7.0 the server used the sealed message and ignored the new one. Safe, since the user's confirmed text won, but the caller was told "done" for something it didn't send:

0.7.0 Β· round 2 with "SWAPPED"

{
  "confirmed": true,
  "echo": "confirm me",
  "mrtr": "confirm_echo",
  "resultType": "complete"
}

0.8.0 Β· round 2 with "SWAPPED"

{
  "code": -32602,
  "message": "message changed since round 1; start again to confirm the new one"
}

The check is one if:

// The sealed message is what the user confirmed.
if message != state.message {
    return Err(McpError::invalid_params(
        "message changed since round 1; start again to confirm the new one",
        None,
    ));
}

6. One error for every bad token

Tampered, sealed for another tool, expired: the client gets the same -32602 for all three. The reason never leaves the server.

let state: ConfirmState = self
    .state_codec
    .open_json_with(sealed, MRTR_AAD)
    // One client-facing error for every failure (tampered, wrong tool,
    // expired), as rmcp's `open_with` asks; the variant stays internal.
    .map_err(|_| McpError::invalid_params(
        "requestState failed integrity check or expired (start again)",
        None,
    ))?;

WHY: rmcp's docs: applications MUST map all token-opening failures to a single client-facing error. A forger learns nothing about which check failed. The changed-message error is different on purpose: it only fires after the token opened cleanly, so it tells a forger nothing.

7. Ask only clients that can answer

Round 1 asks for a form, so it only makes sense for a client that declared it can show one. A client that didn't gets a clear refusal, naming what's missing, instead of a question it can't answer:

{
  "jsonrpc": "2.0",
  "id": 6,
  "error": {
    "code": -32021,
    "message": "Missing required client capability",
    "data": {
      "requiredCapabilities": {
        "elicitation": {}
      }
    }
  }
}

The checklist

# Rule In mcp-better 0.8.0
1 Seal the state; never trust echoed bytes HMAC via rmcp RequestStateCodec
2 Signed isn't secret Only the message goes in, nothing private
3 Put an expiry on every token 5 minutes (CONFIRM_STATE_TTL)
4 Know your reuse window; add a nonce and a store for real effects Stated, not built: it only echoes
5 Bind the token to who called and what they asked Tool name only
6 Refuse changed arguments -32602 "message changed since round 1"
7 One error for every failed open -32602 for tampered, wrong tool, expired
8 Ask only clients that declared the capability -32021 naming elicitation

Try it

npx --yes [email protected] --http
# http://127.0.0.1:8787/mcp

Every request on 2026-07-28 needs an MCP-Protocol-Version header, an Mcp-Method header, an Mcp-Name header for tools/call, and _meta with the protocol version and the client's capabilities. Leave one out and the server tells you which.

Links

Captured from mcp-better 0.7.0 and 0.8.0 over Streamable HTTP, protocol 2026-07-28, on November 27, 2026.

β€” Drafted by Claude Β· Edited by James Wolfe

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.