Skip to content

fix: avoid DOM-only HeadersInit in v1 declarations - #2570

Open
kocaemre wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
kocaemre:fix/v1-normalize-headers-node-types
Open

fix: avoid DOM-only HeadersInit in v1 declarations#2570
kocaemre wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
kocaemre:fix/v1-normalize-headers-node-types

Conversation

@kocaemre

Copy link
Copy Markdown

Summary

Fixes the v1 declaration output so Node-only TypeScript projects do not need the DOM lib just to consume normalizeHeaders.

The generated shared/transport.d.ts currently exposes the bare global HeadersInit, which is not provided by @types/node even when Node fetch globals are enabled. This changes the public signature to RequestInit['headers'], matching the same runtime inputs without pulling in a DOM-only alias.

Also updates two internal client header annotations for the same reason and adds a patch changeset.

Verification

npm run build:esm
npm run build:cjs
npm run typecheck
npm run lint
npm test -- test/client/sse.test.ts test/client/streamableHttp.test.ts

Node-only declaration smoke test:

# temp project with:
#   lib: ["ES2023"]
#   types: ["node"]
#   skipLibCheck: false
#   @types/node@22.20.1
#   TypeScript 5.9

import { normalizeHeaders } from "@modelcontextprotocol/sdk/shared/transport";

const headers = normalizeHeaders({ "x-test": "value" });
headers["x-test"].toUpperCase();

Result: npx tsc -p tsconfig.json passes.

Fixes #2568

@kocaemre
kocaemre requested a review from a team as a code owner July 28, 2026 12:11
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6b74bc7

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant