diff --git a/.changeset/normalize-headers-node-consumers.md b/.changeset/normalize-headers-node-consumers.md new file mode 100644 index 0000000000..9a817fd5bb --- /dev/null +++ b/.changeset/normalize-headers-node-consumers.md @@ -0,0 +1,6 @@ +--- +'@modelcontextprotocol/sdk': patch +--- + +`normalizeHeaders` no longer references the DOM-only global `HeadersInit` in its published declaration. It now uses `RequestInit['headers']`, which `@types/node` binds globally, so Node-only consumers compiling with `skipLibCheck: false` and no `"DOM"` lib no longer fail with +`TS2304: Cannot find name 'HeadersInit'`. Fixes #2568 diff --git a/src/shared/transport.ts b/src/shared/transport.ts index f9b21bed32..18a2d669cc 100644 --- a/src/shared/transport.ts +++ b/src/shared/transport.ts @@ -3,10 +3,10 @@ import { JSONRPCMessage, MessageExtraInfo, RequestId } from '../types.js'; export type FetchLike = (url: string | URL, init?: RequestInit) => Promise; /** - * Normalizes HeadersInit to a plain Record for manipulation. - * Handles Headers objects, arrays of tuples, and plain objects. + * Normalizes header init (Headers instance, array of tuples, or plain object) + * to a plain Record for manipulation. */ -export function normalizeHeaders(headers: HeadersInit | undefined): Record { +export function normalizeHeaders(headers: RequestInit['headers'] | undefined): Record { if (!headers) return {}; if (headers instanceof Headers) {