History

Stamp client identity on MCP execution spans (#1621)

Rhys Sullivan committed 2 months ago

Commit 86c68af1 parent 6dff8916 files · +263 −4Browse files

Showing the changes to apps/cloud/src (1 of 6 files). Show all

Unified · Split

apps/cloud/src/mcp/session-durable-object.ts+4−0
@@ -379,6 +379,10 @@ export class McpSessionDOSqlite extends McpAgentSessionDOBase<Env, CloudSessionD · 378 unmodified lines
379379 // the negotiated apps support comes back from storage instead.
380380 restoredAppsEnabled: sessionMeta.appsEnabled ?? false,
381381 onAppsEnabledChange: (appsEnabled) => self.persistAppsEnabled(appsEnabled),
382+ // Same restore contract for the client identity that keys the
383+ // `mcp.client.*` span attribution on execution spans.
384+ ...(sessionMeta.clientInfo ? { restoredClientInfo: sessionMeta.clientInfo } : {}),
385+ onClientInfoChange: (clientInfo) => self.persistClientInfo(clientInfo),
382386 appsEnabled: false,
383387 sessionful: true,
384388 requestStateSigningKey: self.modernRequestStateSigningKey(),