docs(examples): ext-tasks — a minimal in-process Tasks server and client - #2825
Draft
mattzcarey wants to merge 2 commits into
Draft
mattzcarey wants to merge 2 commits into
mattzcarey wants to merge 2 commits into
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
mattzcarey
added this pull request to stack #2826
September 17, 2026 14:18
One tool, bake_cake, answers with a task handle at once; the work is a plain async function driven by timers that reports progress, asks the client for a frosting (input_required), and honours cancellation between steps. The client installs TasksClientExtension, follows one task to completion through waitFor (answering through tasks/update), cancels a second mid-bake, and checks an unknown id answers -32602. The examples runner now also discovers stories one level down under examples/ext/.
A flat story directory like every other example; the nested-directory discovery in the runner is no longer needed.
mattzcarey
force-pushed
the
feat/tasks-example
branch
from
September 17, 2026 14:24
303d370 to
c4f83bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
examples/ext-tasks: a minimal server and client for the Tasks extension, everything in-process — no queue, no workflow engine, no database. It is the smallest thing that exercises the whole wire.Server.
TasksExtensionover anInMemoryTaskStore, installed withnew McpServer(info, { extensions: [tasks] }). One tool,bake_cake, callstasks.create(ctx)and answers with the task handle at once; the work is a plain async function driven by timers that reports progress throughhandle.status, asks the client which frosting to use throughhandle.requireInput(input_required), and honours cancellation between steps throughhandle.signal.Client.
TasksClientExtensioninstalled on theClient. It calls the tool, follows the task withwaitFor— answering the frosting question throughtasks.updateinsideonUpdate— and asserts the completed result. It then starts a second task and cancels it while it waits for input, and checks an unknown task id answers-32602.Both legs pass locally over stdio and Streamable HTTP; modern era only, since task handles and
tasks/*ride the 2026-07-28 per-request capabilities envelope.Also in this PR
examples/tsconfig.jsonmaps the twoext/taskspackage subpaths (and the sharedcore-internal/ext/taskswire module) to source for typechecking, like the existing subpath entries.examples/README.md.Requires #2782 and #2820.