Skip to content

docs(examples): ext-tasks — a minimal in-process Tasks server and client - #2825

Draft
mattzcarey wants to merge 2 commits into
feat/pluggable-task-workflowfrom
feat/tasks-example
Draft

mattzcarey wants to merge 2 commits into
feat/pluggable-task-workflowfrom
feat/tasks-example

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Draft, third of a stack on #2782 (Tasks extension), which sits on #2820 (extensions). Review the last commit only.

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. TasksExtension over an InMemoryTaskStore, installed with new McpServer(info, { extensions: [tasks] }). One tool, bake_cake, calls tasks.create(ctx) and answers with the task handle at once; the work is a plain async function driven by timers that reports progress through handle.status, asks the client which frosting to use through handle.requireInput (input_required), and honours cancellation between steps through handle.signal.

Client. TasksClientExtension installed on the Client. It calls the tool, follows the task with waitFor — answering the frosting question through tasks.update inside onUpdate — 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.

[client] task … created: working
[client] saw: working (mixing 3 layers) -> input_required (mixing 3 layers) -> completed (baking with chocolate frosting)
[client] task … ended: cancelled

Also in this PR

  • examples/tsconfig.json maps the two ext/tasks package subpaths (and the shared core-internal/ext/tasks wire module) to source for typechecking, like the existing subpath entries.
  • A row in examples/README.md.

Requires #2782 and #2820.

@changeset-bot

changeset-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 303d370

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2825

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2825

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2825

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2825

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2825

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2825

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2825

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2825

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2825

commit: c4f83bf

@mattzcarey mattzcarey changed the title docs(examples): ext/tasks — a minimal in-process Tasks server and client docs(examples): ext-tasks — a minimal in-process Tasks server and client Sep 17, 2026
@mattzcarey
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.
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.

1 participant