-
Notifications
You must be signed in to change notification settings - Fork 37.4k
mcp: implement sep-1732 tasks #277888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mcp: implement sep-1732 tasks #277888
Conversation
Implement full support for both server-side and client-side tasks on tool calls, sampling, and elicitation Refs modelcontextprotocol/modelcontextprotocol#1732
a9f13f0 to
582ef94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements full support for MCP tasks as specified in SEP-1732, enabling both server-side and client-side task-augmented execution for tool calls, sampling, and elicitation requests.
Key Changes
- Adds comprehensive task management infrastructure with
McpTaskManagerfor handling asynchronous task execution, polling, and lifecycle management - Updates the MCP protocol schema to include task-related types, requests, and notifications
- Implements task-augmented request handling for
tools/call,sampling/createMessage, andelicitation/createoperations
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modelContextProtocol.ts | Extensive protocol schema updates including new task types, parameters, requests/responses, and capability negotiation fields |
| mcpTaskManager.ts | New task manager implementation for managing server-side and client-side task state, execution, and lifecycle |
| mcpServerRequestHandler.ts | Adds task augmentation support, client task tracking, polling implementation, and task-related request handlers |
| mcpServerConnection.ts | Integrates task manager into server connections for persistence across reconnections |
| mcpServer.ts | Adds shared task manager instance and implements task hints for tool calls |
| mcpSamplingService.ts | Updates message content handling to support arrays using asArray utility |
| mcpTypes.ts | Updates handler signatures to accept optional CancellationToken parameters |
| mcpTypesUtils.ts | Adds isTaskResult type guard utility |
| mcpRegistry.ts | Threads task manager through connection creation |
| mcpRegistryTypes.ts | Adds task manager to connection options |
| mcpIcons.ts | Adds backward compatibility for icon sizes as strings |
| mcpSamplingLog.test.ts | Updates test assertions to handle array content using asArray |
| mcpIcons.test.ts | Updates test data to use array format for icon sizes |
| mcpServerConnection.test.ts | Adds task manager instances to all test connection creations |
| mcpServerRequestHandler.test.ts | Adds task manager to handler creation in tests |
| chatToolOutputWebviewSubPart.ts | New file for rendering tool outputs using webviews (appears unrelated to tasks) |
| } | ||
|
|
||
| export function isTaskResult(obj: MCP.Result | MCP.CreateTaskResult): obj is MCP.CreateTaskResult { | ||
| return (obj as MCP.CreateTaskResult).task !== undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it time for zod? 👀
|
Cool! |
Implement full support for both server-side and client-side tasks on tool calls, sampling, and elicitation
Refs modelcontextprotocol/modelcontextprotocol#1732