Norilu runs MCP over Streamable HTTP in two directions without keeping an MCP session in either. When a coding agent calls Norilu, every POST to /mcp carries an OAuth access token that is verified on that request alone. When a Norilu agent calls a customer's MCP server, every POST carries a new signed JWT naming the verified customer and user. No request depends on one before it, so no customer's identity can carry over into another's.
This post explains why we made that choice, what the code does on each request, and what it costs.
What a session asks a Worker to remember
The MCP Streamable HTTP transport lets a server return an Mcp-Session-Id during initialize. The client then sends that ID with every later request, and the server is expected to recognize it. In a long-running process, that usually means a map in memory from session ID to transport, connected user and initialization state.
Our dashboard and its MCP endpoint run on Cloudflare Workers. A Worker has no guaranteed affinity between two requests from the same client, and an isolate can be evicted at any time. To keep sessions, we would need a store for session state, sticky routing to a Durable Object, or both. Every deploy and every eviction would then become a recovery problem: which sessions survived, and is the identity attached to each one still valid?
The bigger issue for us is authority. If a server decides who the caller is at initialize and remembers it, every later message inherits that decision. A Norilu workspace can lose a member, change a role or revoke an application's consent between two messages. A remembered session would keep acting on the old answer. With many customers on shared infrastructure, a session table is also one more piece of state that has to be kept strictly separate per tenant. Every mistake there becomes a cross-customer leak.
So the rule is simple: authority comes from the request in hand, checked against current records.
Inbound: verify the token on every POST
The /mcp handler runs the same checks for every HTTP request before a tool can run:
- Verify the bearer as a signed Norilu access token, with issuer, audience (
https://app.norilu.com/mcp) and expiry pinned. Requirenorilu:read. Enforce the DPoP binding when the token has one. - Confirm the user, sign-in session, OAuth client and consent grant still exist. The consent row is put into the token as a claim, so deleting it invalidates tokens that haven't expired.
- Resolve the workspace from
X-Norilu-Workspace, falling back to the personal workspace, and load the caller's current role. - Create a new MCP server, connect it to a transport with
sessionIdGenerator: undefined, handle the one JSON-RPC message and close the server.
Access tokens last five minutes, and clients refresh them with offline_access. Unauthenticated requests get a 401 whose WWW-Authenticate header points at /.well-known/oauth-protected-resource. Standard MCP clients can discover the authorization server, register dynamically and sign in through the browser.
The next boundary is between the Worker and the agent engine. Nothing the client sent is trusted there either. The MCP handler builds each engine request from the verified workspace owner and the parsed tool input. The server, embed and Customer Space APIs cross the same boundary with the same rule:
// Construct trusted headers afresh: no caller identity, cookies or
// bearer credentials cross the boundary.
const headers = new Headers({
"x-norilu-owner": verifiedOwner,
"x-norilu-dashboard-origin": url.origin,
});
On those routes only content-type, accept, mcp-protocol-version and a file-name header are copied across. A forged owner header or a stray cookie from the client never reaches the engine, because the internal request never starts from the client's headers.
Outbound: one shared server, many customers
The second direction matters for teams embedding Norilu agents in their own product. Say a workflow SaaS exposes its data through one MCP server, and each of its customers gets an isolated Customer Space in Norilu. The agent running for customer A needs to call that server as customer A, for the user who started the thread.
The usual options are poor fits. One API key per customer means provisioning, storing and rotating a credential every time a customer is added. One shared key means the server can't tell customers apart and has to trust whatever tenant ID turns up in the tool arguments. The model chose those arguments, so that is the confused-deputy problem in its most direct form.
So we added a third authentication mode for remote MCP connections, norilu_jwt. The SaaS registers its server once in its own Norilu workspace and grants tools to specific saved agents. For each outbound POST, the connector broker signs a new token:
Customer thread Norilu runtime Connector broker Your MCP server
(space, user) (stateless)
│ tools/call │ │ │
├─────────────────────────────►│ │ │
│ │ join stored records: │ │
│ │ thread → space → payer │ │
│ │ → saved agent │ │
│ ├────── verified context ────►│ │
│ │ workspace, space, sub, │ sign EdDSA JWT │
│ │ agent_id, turn_id, call_id │ exp 60s, fresh jti │
│ │ ├── POST + Bearer ──────►│
│ │ │ │ verify via JWKS,
│ │ │ │ scope data to
│ │ │◄────── result ─────────┤ workspace+space+sub
│ │◄──── redacted result ───────┤ │
The context comes from a database join, not from the model. Norilu looks up the engine owner's workspace, its Customer Space binding and payer, and the persisted thread for the session. It checks that the thread belongs to that space and payer and runs the same saved agent. A disabled space, a deleted thread or a mismatch on any of those fails with 403 mcp_context_required before anything is signed. The external user ID stored on the thread becomes sub. A thread created with only a server key and no user has no human subject, so it can't use the gateway.
The broker signs with Ed25519, sets a 60-second expiry and a random jti, and puts the token only on the outbound request. The public keys are served at /.well-known/norilu-mcp-jwks.json with a five-minute cache. If signing isn't configured, calls fail with mcp_signing_unavailable. The broker never generates a key or sends an unsigned request.
What the broker refuses
A stateless gateway only helps if the server can't quietly turn it back into a stateful one. In norilu_jwt mode the broker's fetch wrapper:
- Deletes any
Mcp-Session-Idfrom the outgoing request. - Answers the SDK's optional background GET stream itself with
405, so it never reaches your server without a request-scoped identity. - Rejects anything other than a POST to the exact registered URL, which rules out redirects and off-origin requests.
- Cancels any response that includes
Mcp-Session-Id. Before the tool call is sent, that is409 mcp_stateless_required. After it, the error is502 mcp_unavailable, because the server may already have acted and the caller should check its outcome rather than retry.
Tokens never enter model input, the SSE stream, stored traces or connection records. Known bearer values are redacted from results, metadata and errors. A pattern match also redacts JWT-shaped strings, so a hostile server that echoes another request's token gets nothing useful back.
Approvals still sit in front of all of this. A write tool pauses for a human decision, and the broker signs the request only after the runtime has verified that decision for the exact call_id. After an approval, turn_id names the resumed turn that performs the call, while call_id stays the exact call that was approved.
What it costs
Stateless isn't free, and we'd rather say so up front.
- Verification on every request. Each
/mcpPOST verifies a token and reads current account and workspace records. Each outbound call adds a signature, and your server adds a check against a cached JWKS. - No server push outside a request. Without the background GET stream, your server can't send Norilu unprompted notifications. Responses streamed on a POST still work.
- Replay within 60 seconds. A short-lived JWT isn't single-use. Use
call_id, together with the verified tenant, to deduplicate writes on your side. - Keys are an operational step. Signing keys are provisioned and rotated by hand: publish the new public key, wait out the five-minute cache, then switch signing.
- Your server still decides. A valid signature proves who Norilu says the caller is. Your server still has to pin the issuer, audience and the payer workspaces it serves, and apply its own authorization to the verified
workspace,spaceandsub.
In exchange, there's no session table to restore, no affinity to keep, and nothing in memory that a restart can lose. No request can act on another customer's identity.
Questions
Does Norilu issue an Mcp-Session-Id?
No. Norilu's /mcp endpoint creates a fresh MCP server for each request with session IDs disabled, and the outbound gateway refuses any server response that tries to start a session.
Can my MCP server send Norilu notifications on a background stream?
Not through the stateless gateway. Norilu doesn't open the optional GET event stream. A streamed response to an individual POST is still supported.
Written by The Norilu team.