From c2dae3754614df3c97ad042396f099b9b79c7bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Han=20Uyar?= Date: Thu, 29 Oct 2026 22:10:06 +0300 Subject: [PATCH 1/2] fix: use RequestInit['headers'] in normalizeHeaders The exported signature referenced the bare global HeadersInit, which is declared by the DOM lib only. Node-only consumers that compile with "lib": ["ES2023"], "types": ["node"] and skipLibCheck: false failed with TS2304 on the emitted dist/{esm,cjs}/shared/transport.d.ts. RequestInit is also provided globally by @types/node via undici-types, so its indexed access type resolves without DOM. This matches the signature already shipped on main. Refs #2568 --- .changeset/normalize-headers-node-only-consumers.md | 10 ++++++++++ src/shared/transport.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/normalize-headers-node-only-consumers.md diff --git a/.changeset/normalize-headers-node-only-consumers.md b/.changeset/normalize-headers-node-only-consumers.md new file mode 100644 index 0000000000..7432e7cf5d --- /dev/null +++ b/.changeset/normalize-headers-node-only-consumers.md @@ -0,0 +1,10 @@ +--- +'@modelcontextprotocol/sdk': patch +--- + +Reference `RequestInit['headers']` instead of the bare global `HeadersInit` in `normalizeHeaders`. + +`HeadersInit` is declared by the DOM lib only, while `RequestInit` is also provided globally by `@types/node` through `undici-types`. Consumers that compile the SDK with `"lib": ["ES2023"]`, `"types": ["node"]` and `"skipLibCheck": false` therefore failed with +`TS2304: Cannot find name 'HeadersInit'` on `dist/{esm,cjs}/shared/transport.d.ts`. + +This matches the signature already used on `main`, and resolves the v1 line of the report. diff --git a/src/shared/transport.ts b/src/shared/transport.ts index 2be18ae85b..6bc1ab4c45 100644 --- a/src/shared/transport.ts +++ b/src/shared/transport.ts @@ -6,7 +6,7 @@ export type FetchLike = (url: string | URL, init?: RequestInit) => Promise for manipulation. * Handles Headers objects, arrays of tuples, and plain objects. */ -export function normalizeHeaders(headers: HeadersInit | undefined): Record { +export function normalizeHeaders(headers: RequestInit['headers'] | undefined): Record { if (!headers) return {}; if (headers instanceof Headers) { From 9cfb5d7bcab6ef0b2305355c9953975f0919ed96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Han=20Uyar?= Date: Fri, 30 Oct 2026 00:25:07 +0300 Subject: [PATCH 2/2] docs: drop the DOM-only HeadersInit name from the normalizeHeaders doc comment --- src/shared/transport.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/transport.ts b/src/shared/transport.ts index 6bc1ab4c45..09651e47a1 100644 --- a/src/shared/transport.ts +++ b/src/shared/transport.ts @@ -3,7 +3,7 @@ import { JSONRPCMessage, MessageExtraInfo, RequestId } from '../types.js'; export type FetchLike = (url: string | URL, init?: RequestInit) => Promise; /** - * Normalizes HeadersInit to a plain Record for manipulation. + * Normalizes RequestInit['headers'] to a plain Record for manipulation. * Handles Headers objects, arrays of tuples, and plain objects. */ export function normalizeHeaders(headers: RequestInit['headers'] | undefined): Record {