Skip to content

Commit 65dcf1e

Browse files
address review: remove task mappings from codemod, drop orphaned changeset, complete migration removal lists, fix stale counts, drop leftover task requirement entries
1 parent adb443e commit 65dcf1e

14 files changed

Lines changed: 140 additions & 548 deletions

File tree

.changeset/fix-failed-task-result-retrieval.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/migration-SKILL.md

Lines changed: 69 additions & 66 deletions
Large diffs are not rendered by default.

docs/migration.md

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ const transport = new StreamableHTTPClientTransport(new URL('http://localhost:30
145145

146146
Resource Server helpers (`requireBearerAuth`, `mcpAuthMetadataRouter`, `getOAuthProtectedResourceMetadataUrl`, `OAuthTokenVerifier`) are first-class in `@modelcontextprotocol/express`.
147147

148-
Authorization Server helpers (`mcpAuthRouter`, `OAuthServerProvider`, `ProxyOAuthServerProvider`, `authenticateClient`, `allowedMethods`, etc.) have been removed from the core SDK; new code should use a dedicated IdP/OAuth library. See the [examples](../examples/server/src/) for a working demo with `better-auth`.
148+
Authorization Server helpers (`mcpAuthRouter`, `OAuthServerProvider`, `ProxyOAuthServerProvider`, `authenticateClient`, `allowedMethods`, etc.) have been removed from the core SDK; new code should use a dedicated IdP/OAuth library. See the [examples](../examples/server/src/) for
149+
a working demo with `better-auth`.
149150

150151
Note: `AuthInfo` has moved from `server/auth/types.ts` to the core types and is now re-exported by `@modelcontextprotocol/client` and `@modelcontextprotocol/server`.
151152

@@ -387,7 +388,11 @@ const AcmeSearch = z.object({
387388
params: z.object({ query: z.string(), limit: z.number().int() })
388389
});
389390
server.setRequestHandler(AcmeSearch, async request => {
390-
return { items: [/* ... */] };
391+
return {
392+
items: [
393+
/* ... */
394+
]
395+
};
391396
});
392397
```
393398

@@ -398,7 +403,11 @@ const SearchParams = z.object({ query: z.string(), limit: z.number().int() });
398403
const SearchResult = z.object({ items: z.array(z.string()) });
399404

400405
server.setRequestHandler('acme/search', { params: SearchParams, result: SearchResult }, async (params, ctx) => {
401-
return { items: [/* ... */] };
406+
return {
407+
items: [
408+
/* ... */
409+
]
410+
};
402411
});
403412
```
404413

@@ -437,8 +446,8 @@ Common method string replacements:
437446

438447
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer require a schema parameter for spec methods
439448

440-
For **spec** methods, the public `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` methods no longer require a Zod result schema argument. The SDK now resolves the correct result schema internally based on the method name. This means you no longer need to import result schemas
441-
like `CallToolResultSchema` or `ElicitResultSchema` when making spec-method requests.
449+
For **spec** methods, the public `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` methods no longer require a Zod result schema argument. The SDK now resolves the correct result schema internally based on the method name. This means you no longer need to
450+
import result schemas like `CallToolResultSchema` or `ElicitResultSchema` when making spec-method requests.
442451

443452
**`client.request()` — Before (v1):**
444453

@@ -518,7 +527,8 @@ import { specTypeSchemas } from '@modelcontextprotocol/client';
518527
const result = specTypeSchemas.CallToolResult['~standard'].validate(value);
519528
```
520529

521-
`isSpecType` and `specTypeSchemas` are keyed by `SpecTypeName` — a literal union of every named type in the MCP spec — so you get autocomplete and a compile error on typos. `specTypeSchemas.X` is a `StandardSchemaV1Sync<In, Out>``validate()` returns the result synchronously, so you can access `.issues` / `.value` without `await`. It composes with any Standard-Schema-aware library. The pre-existing `isCallToolResult(value)` guard still works.
530+
`isSpecType` and `specTypeSchemas` are keyed by `SpecTypeName` — a literal union of every named type in the MCP spec — so you get autocomplete and a compile error on typos. `specTypeSchemas.X` is a `StandardSchemaV1Sync<In, Out>``validate()` returns the result synchronously,
531+
so you can access `.issues` / `.value` without `await`. It composes with any Standard-Schema-aware library. The pre-existing `isCallToolResult(value)` guard still works.
522532

523533
### Client list methods return empty results for missing capabilities
524534

@@ -585,21 +595,21 @@ import { JSONRPCErrorResponse, ResourceTemplateReference, isJSONRPCErrorResponse
585595

586596
The `RequestHandlerExtra` type has been replaced with a structured context type hierarchy using nested groups:
587597

588-
| v1 | v2 |
589-
| ---------------------------------------- | ---------------------------------------------------------------------- |
590-
| `RequestHandlerExtra` (flat, all fields) | `ServerContext` (server handlers) or `ClientContext` (client handlers) |
591-
| `extra` parameter name | `ctx` parameter name |
592-
| `extra.signal` | `ctx.mcpReq.signal` |
593-
| `extra.requestId` | `ctx.mcpReq.id` |
594-
| `extra._meta` | `ctx.mcpReq._meta` |
595-
| `extra.sendRequest(...)` | `ctx.mcpReq.send(...)` |
596-
| `extra.sendNotification(...)` | `ctx.mcpReq.notify(...)` |
597-
| `extra.authInfo` | `ctx.http?.authInfo` |
598-
| `extra.requestInfo` | `ctx.http?.req` (standard Web `Request`, only on `ServerContext`) |
599-
| `extra.closeSSEStream` | `ctx.http?.closeSSE` (only on `ServerContext`) |
600-
| `extra.closeStandaloneSSEStream` | `ctx.http?.closeStandaloneSSE` (only on `ServerContext`) |
601-
| `extra.sessionId` | `ctx.sessionId` |
602-
| `extra.taskStore` / `taskId` / `taskRequestedTtl` | _removed — see "Experimental tasks interception removed" below_ |
598+
| v1 | v2 |
599+
| ------------------------------------------------- | ---------------------------------------------------------------------- |
600+
| `RequestHandlerExtra` (flat, all fields) | `ServerContext` (server handlers) or `ClientContext` (client handlers) |
601+
| `extra` parameter name | `ctx` parameter name |
602+
| `extra.signal` | `ctx.mcpReq.signal` |
603+
| `extra.requestId` | `ctx.mcpReq.id` |
604+
| `extra._meta` | `ctx.mcpReq._meta` |
605+
| `extra.sendRequest(...)` | `ctx.mcpReq.send(...)` |
606+
| `extra.sendNotification(...)` | `ctx.mcpReq.notify(...)` |
607+
| `extra.authInfo` | `ctx.http?.authInfo` |
608+
| `extra.requestInfo` | `ctx.http?.req` (standard Web `Request`, only on `ServerContext`) |
609+
| `extra.closeSSEStream` | `ctx.http?.closeSSE` (only on `ServerContext`) |
610+
| `extra.closeStandaloneSSEStream` | `ctx.http?.closeStandaloneSSE` (only on `ServerContext`) |
611+
| `extra.sessionId` | `ctx.sessionId` |
612+
| `extra.taskStore` / `taskId` / `taskRequestedTtl` | _removed — see "Experimental tasks interception removed" below_ |
603613

604614
**Before (v1):**
605615

@@ -712,22 +722,22 @@ try {
712722

713723
The new `SdkErrorCode` enum contains string-valued codes for local SDK errors:
714724

715-
| Code | Description |
716-
| ------------------------------------------------- | ------------------------------------------- |
717-
| `SdkErrorCode.NotConnected` | Transport is not connected |
718-
| `SdkErrorCode.AlreadyConnected` | Transport is already connected |
719-
| `SdkErrorCode.NotInitialized` | Protocol is not initialized |
720-
| `SdkErrorCode.CapabilityNotSupported` | Required capability is not supported |
721-
| `SdkErrorCode.RequestTimeout` | Request timed out waiting for response |
722-
| `SdkErrorCode.ConnectionClosed` | Connection was closed |
723-
| `SdkErrorCode.SendFailed` | Failed to send message |
725+
| Code | Description |
726+
| ------------------------------------------------- | ---------------------------------------------- |
727+
| `SdkErrorCode.NotConnected` | Transport is not connected |
728+
| `SdkErrorCode.AlreadyConnected` | Transport is already connected |
729+
| `SdkErrorCode.NotInitialized` | Protocol is not initialized |
730+
| `SdkErrorCode.CapabilityNotSupported` | Required capability is not supported |
731+
| `SdkErrorCode.RequestTimeout` | Request timed out waiting for response |
732+
| `SdkErrorCode.ConnectionClosed` | Connection was closed |
733+
| `SdkErrorCode.SendFailed` | Failed to send message |
724734
| `SdkErrorCode.InvalidResult` | Response result failed local schema validation |
725-
| `SdkErrorCode.ClientHttpNotImplemented` | HTTP POST request failed |
726-
| `SdkErrorCode.ClientHttpAuthentication` | Server returned 401 after re-authentication |
727-
| `SdkErrorCode.ClientHttpForbidden` | Server returned 403 after trying upscoping |
728-
| `SdkErrorCode.ClientHttpUnexpectedContent` | Unexpected content type in HTTP response |
729-
| `SdkErrorCode.ClientHttpFailedToOpenStream` | Failed to open SSE stream |
730-
| `SdkErrorCode.ClientHttpFailedToTerminateSession` | Failed to terminate session |
735+
| `SdkErrorCode.ClientHttpNotImplemented` | HTTP POST request failed |
736+
| `SdkErrorCode.ClientHttpAuthentication` | Server returned 401 after re-authentication |
737+
| `SdkErrorCode.ClientHttpForbidden` | Server returned 403 after trying upscoping |
738+
| `SdkErrorCode.ClientHttpUnexpectedContent` | Unexpected content type in HTTP response |
739+
| `SdkErrorCode.ClientHttpFailedToOpenStream` | Failed to open SSE stream |
740+
| `SdkErrorCode.ClientHttpFailedToTerminateSession` | Failed to terminate session |
731741

732742
#### `StreamableHTTPError` removed
733743

@@ -756,7 +766,7 @@ try {
756766
await transport.send(message);
757767
} catch (error) {
758768
if (error instanceof SdkHttpError) {
759-
console.log('HTTP status:', error.status); // number — no cast needed
769+
console.log('HTTP status:', error.status); // number — no cast needed
760770
console.log('Status text:', error.statusText); // string | undefined
761771
switch (error.code) {
762772
case SdkErrorCode.ClientHttpAuthentication:
@@ -877,9 +887,9 @@ The 2025-11 experimental tasks side-channel woven through `Protocol` has been re
877887
- `BaseContext.task` (`ctx.task?.store` / `ctx.task?.id` / `ctx.task?.requestedTtl`)
878888
- abstract `assertTaskCapability` / `assertTaskHandlerCapability`
879889
- `client.experimental.tasks.*` / `server.experimental.tasks.*` / `mcpServer.experimental.tasks.*` accessors and the `Experimental{Client,Server,McpServer}Tasks` classes
880-
- streaming methods (`requestStream`, `callToolStream`, `createMessageStream`, `elicitInputStream`) and the `ResponseMessage` types they yielded
890+
- streaming methods (`requestStream`, `callToolStream`, `createMessageStream`, `elicitInputStream`) and the `ResponseMessage` types they yielded (`BaseResponseMessage`, `ErrorMessage`, `AsyncGeneratorValue`)
881891
- `mcpServer.experimental.tasks.registerToolTask(...)`, `ToolTaskHandler`, `TaskRequestHandler`, `CreateTaskRequestHandler`
882-
- `TaskMessageQueue`, `InMemoryTaskMessageQueue`, `Queued*` message types, `CreateTaskServerContext`, `TaskServerContext`, `TaskToolExecution`
892+
- `TaskMessageQueue`, `InMemoryTaskMessageQueue`, `BaseQueuedMessage` and the `Queued*` message types, `CreateTaskServerContext`, `TaskServerContext`, `TaskToolExecution`
883893
- `examples/{client,server}/src/simpleTaskInteractive*.ts`
884894

885895
**Also removed:** the storage layer (`TaskStore`, `InMemoryTaskStore`, `CreateTaskOptions`, `isTerminal`) and `TaskCreationParams`. They will return as part of the SEP-2663 server-directed plugin in a follow-up.
@@ -924,7 +934,8 @@ const server = new McpServer(
924934
);
925935
```
926936

927-
You do not need to install or import validator packages for the default behavior. The client and server packages bundle the validator backend selected by the runtime shim, so a normal `import { McpServer } from '@modelcontextprotocol/server'` does not pull `ajv` or `@cfworker/json-schema` into your bundle until you choose to customize.
937+
You do not need to install or import validator packages for the default behavior. The client and server packages bundle the validator backend selected by the runtime shim, so a normal `import { McpServer } from '@modelcontextprotocol/server'` does not pull `ajv` or
938+
`@cfworker/json-schema` into your bundle until you choose to customize.
928939

929940
If you want to customize the **built-in** backend (for example, pre-register schemas by `$id`, register custom AJV formats, or change the `@cfworker/json-schema` draft), import the named class from the explicit subpath and pass an instance through `jsonSchemaValidator`:
930941

@@ -959,7 +970,8 @@ const server = new McpServer(
959970

960971
(both subpaths are also available on `@modelcontextprotocol/client/validators/...`)
961972

962-
If you import from one of these subpaths in your own code, the corresponding peer dep (`ajv` + `ajv-formats`, or `@cfworker/json-schema`) needs to be installed in your `package.json`. The runtime shim continues to vendor a copy for the default code path, so you can use the subpath in some files and rely on the default in others.
973+
If you import from one of these subpaths in your own code, the corresponding peer dep (`ajv` + `ajv-formats`, or `@cfworker/json-schema`) needs to be installed in your `package.json`. The runtime shim continues to vendor a copy for the default code path, so you can use the
974+
subpath in some files and rely on the default in others.
963975

964976
To replace validation wholesale rather than customizing the built-in classes, implement the `jsonSchemaValidator` interface and pass your own implementation through the option above.
965977

packages/codemod/src/generated/specSchemaMap.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export const SPEC_SCHEMA_NAMES: ReadonlySet<string> = new Set([
88
'CallToolRequestParamsSchema',
99
'CallToolRequestSchema',
1010
'CallToolResultSchema',
11-
'CancelTaskRequestSchema',
12-
'CancelTaskResultSchema',
1311
'CancelledNotificationParamsSchema',
1412
'CancelledNotificationSchema',
1513
'ClientCapabilitiesSchema',
@@ -25,7 +23,6 @@ export const SPEC_SCHEMA_NAMES: ReadonlySet<string> = new Set([
2523
'CreateMessageRequestSchema',
2624
'CreateMessageResultSchema',
2725
'CreateMessageResultWithToolsSchema',
28-
'CreateTaskResultSchema',
2926
'CursorSchema',
3027
'ElicitRequestFormParamsSchema',
3128
'ElicitRequestParamsSchema',
@@ -40,10 +37,6 @@ export const SPEC_SCHEMA_NAMES: ReadonlySet<string> = new Set([
4037
'GetPromptRequestParamsSchema',
4138
'GetPromptRequestSchema',
4239
'GetPromptResultSchema',
43-
'GetTaskPayloadRequestSchema',
44-
'GetTaskPayloadResultSchema',
45-
'GetTaskRequestSchema',
46-
'GetTaskResultSchema',
4740
'IconSchema',
4841
'IconsSchema',
4942
'ImageContentSchema',
@@ -70,8 +63,6 @@ export const SPEC_SCHEMA_NAMES: ReadonlySet<string> = new Set([
7063
'ListResourcesResultSchema',
7164
'ListRootsRequestSchema',
7265
'ListRootsResultSchema',
73-
'ListTasksRequestSchema',
74-
'ListTasksResultSchema',
7566
'ListToolsRequestSchema',
7667
'ListToolsResultSchema',
7768
'LoggingLevelSchema',
@@ -110,7 +101,6 @@ export const SPEC_SCHEMA_NAMES: ReadonlySet<string> = new Set([
110101
'ReadResourceRequestParamsSchema',
111102
'ReadResourceRequestSchema',
112103
'ReadResourceResultSchema',
113-
'RelatedTaskMetadataSchema',
114104
'RequestIdSchema',
115105
'RequestMetaSchema',
116106
'RequestSchema',
@@ -140,13 +130,6 @@ export const SPEC_SCHEMA_NAMES: ReadonlySet<string> = new Set([
140130
'StringSchemaSchema',
141131
'SubscribeRequestParamsSchema',
142132
'SubscribeRequestSchema',
143-
'TaskAugmentedRequestParamsSchema',
144-
'TaskCreationParamsSchema',
145-
'TaskMetadataSchema',
146-
'TaskSchema',
147-
'TaskStatusNotificationParamsSchema',
148-
'TaskStatusNotificationSchema',
149-
'TaskStatusSchema',
150133
'TextContentSchema',
151134
'TextResourceContentsSchema',
152135
'TitledMultiSelectEnumSchemaSchema',

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ export const CONTEXT_PROPERTY_MAP: ContextMapping[] = [
1313
{ from: '.sessionId', to: '.sessionId' },
1414
{ from: '.requestInfo', to: '.http?.req' },
1515
{ from: '.closeSSEStream', to: '.http?.closeSSE' },
16-
{ from: '.closeStandaloneSSEStream', to: '.http?.closeStandaloneSSE' },
17-
{ from: '.taskStore', to: '.task?.store' },
18-
{ from: '.taskId', to: '.task?.id' },
19-
{ from: '.taskRequestedTtl', to: '.task?.requestedTtl' }
16+
{ from: '.closeStandaloneSSEStream', to: '.http?.closeStandaloneSSE' }
2017
];
2118

2219
export const EXTRA_PARAM_NAME = 'extra';

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ export const IMPORT_MAP: Record<string, ImportMapping> = {
152152
},
153153

154154
'@modelcontextprotocol/sdk/experimental/tasks': {
155-
target: '@modelcontextprotocol/server',
156-
status: 'moved'
155+
target: '',
156+
status: 'removed',
157+
removalMessage: 'Experimental tasks removed in v2 (SEP-2663 — tasks moved to the Extensions Track). No v2 equivalent.'
157158
},
158159
'@modelcontextprotocol/sdk/experimental/tasks.js': {
159-
target: '@modelcontextprotocol/server',
160-
status: 'moved'
160+
target: '',
161+
status: 'removed',
162+
removalMessage: 'Experimental tasks removed in v2 (SEP-2663 — tasks moved to the Extensions Track). No v2 equivalent.'
161163
},
162164

163165
'@modelcontextprotocol/sdk/inMemory.js': {

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

Lines changed: 1 addition & 6 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-
ListTasksRequestSchema: 'tasks/list',
19-
GetTaskRequestSchema: 'tasks/get',
20-
GetTaskPayloadRequestSchema: 'tasks/result',
21-
CancelTaskRequestSchema: 'tasks/cancel'
17+
ListRootsRequestSchema: 'roots/list'
2218
};
2319

2420
export const NOTIFICATION_SCHEMA_TO_METHOD: Record<string, string> = {
@@ -31,6 +27,5 @@ export const NOTIFICATION_SCHEMA_TO_METHOD: Record<string, string> = {
3127
CancelledNotificationSchema: 'notifications/cancelled',
3228
InitializedNotificationSchema: 'notifications/initialized',
3329
RootsListChangedNotificationSchema: 'notifications/roots/list_changed',
34-
TaskStatusNotificationSchema: 'notifications/tasks/status',
3530
ElicitationCompleteNotificationSchema: 'notifications/elicitation/complete'
3631
};

0 commit comments

Comments
 (0)