Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@felixweinberger
Copy link
Contributor

@felixweinberger felixweinberger commented Feb 2, 2026

Extracts experimental task orchestration logic from Protocol into a dedicated TaskManager class.

Protocol.ts drops from 1,736 to 992 lines. Task handler registration, message queuing, polling, and state management now live in TaskManager.

Protocol delegates through 5 lifecycle methods (processInboundRequest, processOutboundRequest, processInboundResponse, processOutboundNotification, onClose) and a NullTaskManager provides no-op defaults when tasks are not configured.

Motivation and Context

Task logic was spread across every major Protocol method, making it hard to reason about either concern independently. Since tasks are experimental, this isolation makes Protocol easier to maintain.

Breaking Changes

  • ProtocolOptions.taskStore / taskMessageQueue / etc. moved under ProtocolOptions.tasks?: TaskManagerOptions

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: c76a53b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/core Minor
@modelcontextprotocol/client Minor
@modelcontextprotocol/server Minor
@modelcontextprotocol/node Major
@modelcontextprotocol/express Major
@modelcontextprotocol/hono Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1449

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1449

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1449

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1449

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1449

commit: c76a53b

@felixweinberger felixweinberger changed the title refactor: extract task orchestration from Protocol into TaskManager [RFC] refactor: extract task orchestration from Protocol into TaskManager Feb 3, 2026
@felixweinberger felixweinberger force-pushed the fweinberger/extract-tasks-from-protocol branch from c3104d6 to b783fcd Compare February 3, 2026 10:06
@felixweinberger felixweinberger force-pushed the fweinberger/extract-tasks-from-protocol branch 5 times, most recently from 1cf942d to adf1507 Compare February 3, 2026 21:47
Extract all task-related logic from Protocol into a dedicated TaskManager
class with consolidated lifecycle API and NullTaskManager (Null Object pattern).

Protocol delegates to TaskManager via 4 lifecycle methods:
- processInboundRequest: context extraction + function wrapping
- processOutboundRequest: metadata augmentation + queue routing
- processInboundResponse: side-channel handling + progress preservation
- processOutboundNotification: task-related notification routing

NullTaskManager provides no-op defaults, eliminating all conditional
checks in Protocol.
@felixweinberger felixweinberger force-pushed the fweinberger/extract-tasks-from-protocol branch from adf1507 to c76a53b Compare February 3, 2026 21:51
Comment on lines +183 to +185
return {
...task
} as Result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Task not satisfy GetTaskResult already?

Comment on lines +181 to +182
// Per spec: tasks/get responses SHALL NOT include related-task metadata
// as the taskId parameter is the source of truth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think this comment is relevant here?

@LucaButBoring
Copy link
Contributor

Does this affect how task tools are registered and executed as well? It doesn't look like it does, but I just wanted to verify that first - I believe this supersedes #1315, but I'm unsure if it supersedes #1332 as well or not.

Looks good overall though, I have similar problems in the Java SDK (modelcontextprotocol/java-sdk#755) and will probably copy part of this approach over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants