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
5 changes: 5 additions & 0 deletions .changeset/node-only-normalize-headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/sdk': patch
---

Avoid referencing the DOM-only `HeadersInit` global in emitted transport declarations so Node-only TypeScript projects can compile with `skipLibCheck: false`.
2 changes: 1 addition & 1 deletion src/client/sse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class SSEClientTransport implements Transport {
}

private async _commonHeaders(): Promise<Headers> {
const headers: HeadersInit & Record<string, string> = {};
const headers: RequestInit['headers'] & Record<string, string> = {};
if (this._authProvider) {
const tokens = await this._authProvider.tokens();
if (tokens) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/streamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class StreamableHTTPClientTransport implements Transport {
}

private async _commonHeaders(): Promise<Headers> {
const headers: HeadersInit & Record<string, string> = {};
const headers: RequestInit['headers'] & Record<string, string> = {};
if (this._authProvider) {
const tokens = await this._authProvider.tokens();
if (tokens) {
Expand Down
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 request 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