Skip to content

Commit 75e2a21

Browse files
fix(merge): drop codemod task-method entries (SEP-2663); fix consumer CHANGELOG core-internal refs
1 parent 7b5acf0 commit 75e2a21

7 files changed

Lines changed: 71 additions & 28 deletions

File tree

.changeset/codemod-task-handler-methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@modelcontextprotocol/codemod': patch
33
---
44

5-
Map the task request/notification schemas to their v2 method strings in the handler-registration transform. `setRequestHandler(GetTaskRequestSchema, …)`, `setNotificationHandler(TaskStatusNotificationSchema, …)`, and the other task handlers (`tasks/get`, `tasks/result`, `tasks/list`, `tasks/cancel`, `notifications/tasks/status`) now rewrite to the v2 two-argument method-string form instead of falling through to the generic "use the 3-argument form" manual-migration diagnostic.
5+
Emit a dedicated action-required diagnostic for v1 task-handler registrations (`setRequestHandler(GetTaskRequestSchema, …)`, `setNotificationHandler(TaskStatusNotificationSchema, …)`, and the other `tasks/*` schemas). The experimental tasks feature was removed in v2 (SEP-2663) and the `tasks/*` method strings are excluded from the typed `RequestMethod` / `NotificationMethod` surface, so these registrations are **not** rewritten to method-string form — the codemod marks each site with an `@mcp-codemod-error` comment pointing at the migration guide's tasks-removed section instead.

docs/migration/upgrade-to-v2.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ In addition the codemod:
7676
spec methods.
7777
- Routes the spec Zod `*Schema` constants imported from `sdk/types.js` to
7878
`@modelcontextprotocol/core` (mixed imports are split; `.parse()` / `.safeParse()`
79-
calls are left untouched). The task-handler schema constants
80-
(`GetTaskRequestSchema` etc.) used as `setRequestHandler` args are mapped to their
81-
method strings (`'tasks/get'` etc.) like every other handler schema.
79+
calls are left untouched). Task-handler schema constants
80+
(`GetTaskRequestSchema` etc.) used as `setRequestHandler` args are **not** rewritten
81+
— the experimental tasks feature was removed (SEP-2663), so each such registration
82+
is marked with an action-required diagnostic instead (see
83+
[Experimental tasks interception removed](#experimental-tasks-interception-removed)).
8284
- Renames `ErrorCode``ProtocolErrorCode` and routes the local-only members
8385
(`RequestTimeout`, `ConnectionClosed`) to `SdkErrorCode`.
8486
- Renames every `StreamableHTTPError` reference to `SdkHttpError` and adds the import

packages/client/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
- [#2275](https://github.com/modelcontextprotocol/typescript-sdk/pull/2275) [`1b53a41`](https://github.com/modelcontextprotocol/typescript-sdk/commit/1b53a415ea2c33aa11ac413fc9c2d68ccffde784) Thanks [@KKonstantinov](https://github.com/KKonstantinov)! - Add a configurable
7575
`maxBufferSize` (default 10 MB) to the stdio transports. When a single message would push the read buffer past the limit, the transport now emits an `onerror` and closes instead of growing the buffer unbounded. Configure via `new StdioClientTransport({ ..., maxBufferSize })` or
76-
`new StdioServerTransport(stdin, stdout, { maxBufferSize })`. The default is exported from `@modelcontextprotocol/core-internal` as `STDIO_DEFAULT_MAX_BUFFER_SIZE`.
76+
`new StdioServerTransport(stdin, stdout, { maxBufferSize })`. The default is exported from `@modelcontextprotocol/client` / `@modelcontextprotocol/server` as `STDIO_DEFAULT_MAX_BUFFER_SIZE`.
7777

7878
- [#2088](https://github.com/modelcontextprotocol/typescript-sdk/pull/2088) [`16d13ab`](https://github.com/modelcontextprotocol/typescript-sdk/commit/16d13abf78b5dba5de73dfa284325b13d4219bb2) Thanks [@mattzcarey](https://github.com/mattzcarey)! - Bundle automatic JSON Schema
7979
validator defaults in `@modelcontextprotocol/client` and `@modelcontextprotocol/server` runtime shims.
@@ -160,7 +160,8 @@
160160
For raw JSON Schema (e.g. TypeBox output), use the new `fromJsonSchema` adapter:
161161

162162
```typescript
163-
import { fromJsonSchema, AjvJsonSchemaValidator } from '@modelcontextprotocol/core-internal';
163+
import { fromJsonSchema } from '@modelcontextprotocol/server';
164+
import { AjvJsonSchemaValidator } from '@modelcontextprotocol/server/validators/ajv';
164165
165166
server.registerTool(
166167
'greet',

packages/codemod/src/migrations/v1-to-v2/mappings/schemaToMethodMap.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ export const SCHEMA_TO_METHOD: Record<string, string> = {
1414
SetLevelRequestSchema: 'logging/setLevel',
1515
PingRequestSchema: 'ping',
1616
CompleteRequestSchema: 'completion/complete',
17-
ListRootsRequestSchema: 'roots/list',
18-
GetTaskRequestSchema: 'tasks/get',
19-
GetTaskPayloadRequestSchema: 'tasks/result',
20-
ListTasksRequestSchema: 'tasks/list',
21-
CancelTaskRequestSchema: 'tasks/cancel'
17+
ListRootsRequestSchema: 'roots/list'
2218
};
2319

2420
export const NOTIFICATION_SCHEMA_TO_METHOD: Record<string, string> = {
@@ -31,6 +27,21 @@ export const NOTIFICATION_SCHEMA_TO_METHOD: Record<string, string> = {
3127
CancelledNotificationSchema: 'notifications/cancelled',
3228
InitializedNotificationSchema: 'notifications/initialized',
3329
RootsListChangedNotificationSchema: 'notifications/roots/list_changed',
34-
ElicitationCompleteNotificationSchema: 'notifications/elicitation/complete',
35-
TaskStatusNotificationSchema: 'notifications/tasks/status'
30+
ElicitationCompleteNotificationSchema: 'notifications/elicitation/complete'
3631
};
32+
33+
/**
34+
* v1 task-handler schema names. The experimental tasks feature was removed in v2
35+
* (SEP-2663) and the task method strings are excluded from the typed
36+
* `RequestMethod` / `NotificationMethod` surface, so these are NOT in the rewrite
37+
* maps above — the handler-registration transform emits a dedicated
38+
* action-required diagnostic instead.
39+
*/
40+
export const REMOVED_TASK_SCHEMAS: ReadonlySet<string> = new Set([
41+
'GetTaskRequestSchema',
42+
'GetTaskPayloadRequestSchema',
43+
'ListTasksRequestSchema',
44+
'CancelTaskRequestSchema',
45+
'CreateTaskRequestSchema',
46+
'TaskStatusNotificationSchema'
47+
]);

packages/codemod/src/migrations/v1-to-v2/transforms/handlerRegistration.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Node, SyntaxKind } from 'ts-morph';
44
import type { Diagnostic, Transform, TransformContext, TransformResult } from '../../../types';
55
import { actionRequired } from '../../../utils/diagnostics';
66
import { hasMcpImports, isImportedFromMcp, removeUnusedImport, resolveOriginalImportName } from '../../../utils/importUtils';
7-
import { NOTIFICATION_SCHEMA_TO_METHOD, SCHEMA_TO_METHOD } from '../mappings/schemaToMethodMap';
7+
import { NOTIFICATION_SCHEMA_TO_METHOD, REMOVED_TASK_SCHEMAS, SCHEMA_TO_METHOD } from '../mappings/schemaToMethodMap';
88

99
const ALL_SCHEMA_TO_METHOD: Record<string, string> = {
1010
...SCHEMA_TO_METHOD,
@@ -41,6 +41,21 @@ export const handlerRegistrationTransform: Transform = {
4141

4242
const schemaName = firstArg.getText();
4343
const originalName = resolveOriginalImportName(sourceFile, schemaName) ?? schemaName;
44+
45+
if (REMOVED_TASK_SCHEMAS.has(originalName) && isImportedFromMcp(sourceFile, schemaName)) {
46+
diagnostics.push(
47+
actionRequired(
48+
sourceFile.getFilePath(),
49+
call,
50+
`Task handler registration: ${methodName}(${schemaName}, ...). ` +
51+
`The experimental tasks feature was removed in v2 (SEP-2663); the tasks/* method strings ` +
52+
`are not part of the typed RequestMethod surface. Remove this registration. ` +
53+
`See docs/migration/upgrade-to-v2.md#experimental-tasks-interception-removed.`
54+
)
55+
);
56+
continue;
57+
}
58+
4459
const methodString = ALL_SCHEMA_TO_METHOD[originalName];
4560
if (!methodString) {
4661
diagnostics.push(

packages/codemod/test/v1-to-v2/transforms/handlerRegistration.test.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,39 @@ describe('handler-registration transform', () => {
219219
expect(result).not.toContain('ElicitationCompleteNotificationSchema');
220220
});
221221

222-
it('replaces TaskStatusNotificationSchema with the tasks/status method string', () => {
222+
it('emits a tasks-removed diagnostic for GetTaskRequestSchema (does NOT rewrite to tasks/get)', () => {
223223
const input = [
224-
`import { TaskStatusNotificationSchema } from '@modelcontextprotocol/sdk/types.js';`,
225-
`client.setNotificationHandler(TaskStatusNotificationSchema, async () => {});`,
224+
`import { GetTaskRequestSchema } from '@modelcontextprotocol/sdk/types.js';`,
225+
`server.setRequestHandler(GetTaskRequestSchema, async () => ({}));`,
226226
''
227227
].join('\n');
228-
const result = applyTransform(input);
229-
expect(result).toContain("setNotificationHandler('notifications/tasks/status'");
230-
expect(result).not.toContain('TaskStatusNotificationSchema');
228+
const project = new Project({ useInMemoryFileSystem: true });
229+
const sourceFile = project.createSourceFile('test.ts', input);
230+
const result = handlerRegistrationTransform.apply(sourceFile, ctx);
231+
const text = sourceFile.getFullText();
232+
expect(text).not.toContain("'tasks/get'");
233+
expect(text).toContain('setRequestHandler(GetTaskRequestSchema');
234+
expect(result.changesCount).toBe(0);
235+
expect(result.diagnostics.length).toBe(1);
236+
expect(result.diagnostics[0]!.message).toContain('Task handler registration');
237+
expect(result.diagnostics[0]!.message).toContain('SEP-2663');
231238
});
232239

233-
it('replaces task request schemas (GetTaskRequestSchema → tasks/get)', () => {
240+
it('emits a tasks-removed diagnostic for TaskStatusNotificationSchema (does NOT rewrite)', () => {
234241
const input = [
235-
`import { GetTaskRequestSchema } from '@modelcontextprotocol/sdk/types.js';`,
236-
`server.setRequestHandler(GetTaskRequestSchema, async () => ({}));`,
242+
`import { TaskStatusNotificationSchema } from '@modelcontextprotocol/sdk/types.js';`,
243+
`client.setNotificationHandler(TaskStatusNotificationSchema, async () => {});`,
237244
''
238245
].join('\n');
239-
const result = applyTransform(input);
240-
expect(result).toContain("setRequestHandler('tasks/get'");
241-
expect(result).not.toContain('GetTaskRequestSchema');
246+
const project = new Project({ useInMemoryFileSystem: true });
247+
const sourceFile = project.createSourceFile('test.ts', input);
248+
const result = handlerRegistrationTransform.apply(sourceFile, ctx);
249+
const text = sourceFile.getFullText();
250+
expect(text).not.toContain("'notifications/tasks/status'");
251+
expect(text).toContain('setNotificationHandler(TaskStatusNotificationSchema');
252+
expect(result.changesCount).toBe(0);
253+
expect(result.diagnostics.length).toBe(1);
254+
expect(result.diagnostics[0]!.message).toContain('Task handler registration');
242255
});
243256

244257
it('does not emit diagnostic when first arg is a string literal (v2 style)', () => {

packages/server/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
- [#2275](https://github.com/modelcontextprotocol/typescript-sdk/pull/2275) [`1b53a41`](https://github.com/modelcontextprotocol/typescript-sdk/commit/1b53a415ea2c33aa11ac413fc9c2d68ccffde784) Thanks [@KKonstantinov](https://github.com/KKonstantinov)! - Add a configurable
8383
`maxBufferSize` (default 10 MB) to the stdio transports. When a single message would push the read buffer past the limit, the transport now emits an `onerror` and closes instead of growing the buffer unbounded. Configure via `new StdioClientTransport({ ..., maxBufferSize })` or
84-
`new StdioServerTransport(stdin, stdout, { maxBufferSize })`. The default is exported from `@modelcontextprotocol/core-internal` as `STDIO_DEFAULT_MAX_BUFFER_SIZE`.
84+
`new StdioServerTransport(stdin, stdout, { maxBufferSize })`. The default is exported from `@modelcontextprotocol/client` / `@modelcontextprotocol/server` as `STDIO_DEFAULT_MAX_BUFFER_SIZE`.
8585

8686
- [#2088](https://github.com/modelcontextprotocol/typescript-sdk/pull/2088) [`16d13ab`](https://github.com/modelcontextprotocol/typescript-sdk/commit/16d13abf78b5dba5de73dfa284325b13d4219bb2) Thanks [@mattzcarey](https://github.com/mattzcarey)! - Bundle automatic JSON Schema
8787
validator defaults in `@modelcontextprotocol/client` and `@modelcontextprotocol/server` runtime shims.
@@ -158,7 +158,8 @@
158158
For raw JSON Schema (e.g. TypeBox output), use the new `fromJsonSchema` adapter:
159159

160160
```typescript
161-
import { fromJsonSchema, AjvJsonSchemaValidator } from '@modelcontextprotocol/core-internal';
161+
import { fromJsonSchema } from '@modelcontextprotocol/server';
162+
import { AjvJsonSchemaValidator } from '@modelcontextprotocol/server/validators/ajv';
162163
163164
server.registerTool(
164165
'greet',

0 commit comments

Comments
 (0)