Skip to content

Commit c121658

Browse files
committed
session id guard
1 parent aecd8c6 commit c121658

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/core/src/integrations/mcp-server/sessionExtraction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,13 @@ export function getTransportTypes(transport: MCPTransport): { mcpTransport: stri
176176
* @param transport - MCP transport instance
177177
* @param extra - Optional extra handler data
178178
* @returns Transport attributes for span instrumentation
179+
* @note sessionId may be undefined during initial setup - session should be established by client during initialize flow
179180
*/
180181
export function buildTransportAttributes(
181182
transport: MCPTransport,
182183
extra?: ExtraHandlerData,
183184
): Record<string, string | number> {
184-
const sessionId = transport.sessionId;
185+
const sessionId = transport && 'sessionId' in transport ? transport.sessionId : undefined;
185186
const clientInfo = extra ? extractClientInfo(extra) : {};
186187
const { mcpTransport, networkTransport } = getTransportTypes(transport);
187188
const clientAttributes = getClientAttributes(transport);

0 commit comments

Comments
 (0)