Skip to content

Commit 325b49d

Browse files
Merge remote-tracking branch 'origin/fweinberger/v2-bc-type-aliases' into fweinberger/v2-bc-d1-base
2 parents 3067757 + 93e9c80 commit 325b49d

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modelcontextprotocol/core': patch
3+
'@modelcontextprotocol/client': patch
4+
'@modelcontextprotocol/server': patch
5+
---
6+
7+
Add v1 type aliases to the public API surface for smoother migration: `IsomorphicHeaders` (→ `Headers`) and `RequestInfo` (→ `Request`). `FetchLike` retains its v1 name.

packages/core/src/exports/public/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,26 @@ export type { CfWorkerSchemaDraft } from '../../validators/cfWorkerProvider.js';
200200
// fromJsonSchema is intentionally NOT exported here — the server and client packages
201201
// provide runtime-aware wrappers that default to the appropriate validator via _shims.
202202
export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from '../../validators/types.js';
203+
204+
// ────────────────────────────────────────────────────────────────────────────
205+
// v1 backwards-compatibility type aliases
206+
// ────────────────────────────────────────────────────────────────────────────
207+
208+
// Note: a `ResourceTemplate = ResourceTemplateType` alias is intentionally NOT
209+
// exported here — it conflicts with the server's `ResourceTemplate` class under
210+
// tsdown bundling. The alias lives only in the `/sdk` meta-package's `types.js`.
211+
212+
/**
213+
* @deprecated Use the standard `Headers` web type. v2 transports surface
214+
* request headers via `Headers` on `ctx.http?.req`.
215+
*/
216+
export type IsomorphicHeaders = Headers;
217+
218+
/**
219+
* @deprecated Use the standard `Request` web type. v2's {@linkcode ServerContext}
220+
* exposes the originating HTTP request at `ctx.http?.req`.
221+
*/
222+
export type RequestInfo = globalThis.Request;
223+
224+
// `FetchLike` keeps its v1 name and is re-exported above from
225+
// '../../shared/transport.js' — no alias needed.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { describe, expect, expectTypeOf, test } from 'vitest';
2+
import type { FetchLike, IsomorphicHeaders, RequestInfo } from '../../src/exports/public/index.js';
3+
4+
describe('v1 compat type aliases (core/public)', () => {
5+
test('IsomorphicHeaders aliases the standard Headers type', () => {
6+
expectTypeOf<IsomorphicHeaders>().toEqualTypeOf<Headers>();
7+
const h: IsomorphicHeaders = new Headers({ 'content-type': 'application/json' });
8+
expect(h.get('content-type')).toBe('application/json');
9+
});
10+
11+
test('RequestInfo aliases the standard Request type', () => {
12+
expectTypeOf<RequestInfo>().toEqualTypeOf<Request>();
13+
const r: RequestInfo = new Request('http://localhost/mcp');
14+
expect(r.url).toBe('http://localhost/mcp');
15+
});
16+
17+
test('FetchLike is re-exported', () => {
18+
const f: FetchLike = (url, init) => fetch(url, init);
19+
expect(typeof f).toBe('function');
20+
});
21+
});

0 commit comments

Comments
 (0)