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: 10b945a

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

@claude claude Bot added the v1 Issues / PRs related to v1.x label Aug 18, 2026
@kocaemre

Copy link
Copy Markdown
Author

Rebased this branch onto current v1.x (a9f6eb70) to clear the stale branch state.

Re-ran the relevant local checks after the rebase:

npm ci
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
git diff --check upstream/v1.x..HEAD

Results: ESM/CJS builds passed, typecheck passed, lint/prettier passed, focused client transport tests passed (65 passed), and git diff --check was clean.

Note: before npm ci, the local checkout had drifted to zod@4.3.6 and npm run typecheck failed in existing tests that still use the Zod v3 z.record(valueSchema) call shape. npm ci restored the lockfile version (zod@3.25.76), after which the checks above passed.

@kocaemre
kocaemre force-pushed the fix/v1-normalize-headers-node-types branch from 6b74bc7 to 10b945a Compare August 28, 2026 18:08
@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@2570

commit: 10b945a

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

Labels

v1 Issues / PRs related to v1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant