Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/normalize-headers-node-consumers.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions src/shared/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { JSONRPCMessage, MessageExtraInfo, RequestId } from '../types.js';
export type FetchLike = (url: string | URL, init?: RequestInit) => Promise<Response>;

/**
* Normalizes HeadersInit to a plain Record<string, string> 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<string, string> for manipulation.
*/
export function normalizeHeaders(headers: HeadersInit | undefined): Record<string, string> {
export function normalizeHeaders(headers: RequestInit['headers'] | undefined): Record<string, string> {
if (!headers) return {};

if (headers instanceof Headers) {
Expand Down
Loading