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
10 changes: 10 additions & 0 deletions .changeset/normalize-headers-node-only-consumers.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 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.
* Normalizes RequestInit['headers'] to a plain Record<string, string> for manipulation.
* Handles Headers objects, arrays of tuples, and plain objects.
*/
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