Skip to content

Commit 4643bbc

Browse files
test(middleware/node): derive mcp-protocol-version in the conformant-client header helper
1 parent c0b96b0 commit 4643bbc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

packages/middleware/node/test/toNodeHandler.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ function modernToolsCall(name: string, args: Record<string, unknown>): unknown {
4040
function bodyDerivedStandardHeaders(body: unknown): Record<string, string> {
4141
if (body === null || typeof body !== 'object' || Array.isArray(body)) return {};
4242
const b = body as { method?: unknown; params?: { name?: unknown; uri?: unknown; _meta?: Record<string, unknown> } };
43-
if (typeof b.params?._meta?.[PROTOCOL_VERSION_META_KEY] !== 'string') return {};
44-
const out: Record<string, string> = {};
43+
const claimedVersion = b.params?._meta?.[PROTOCOL_VERSION_META_KEY];
44+
if (typeof claimedVersion !== 'string') return {};
45+
const out: Record<string, string> = { 'mcp-protocol-version': claimedVersion };
4546
if (typeof b.method === 'string') out['mcp-method'] = b.method;
46-
const name = b.method === 'resources/read' ? b.params.uri : b.params.name;
47+
const name = b.method === 'resources/read' ? b.params?.uri : b.params?.name;
4748
if (typeof name === 'string') out['mcp-name'] = name;
4849
return out;
4950
}

0 commit comments

Comments
 (0)