Repository navigation
v0.3.0
v0.3.0 adds the 2026-07-28 Tasks extension (io.modelcontextprotocol/tasks) to the server and the client.
Highlights
- Long-running tools as tasks. A tool handler can answer a
tools/callwith a task by returningserver.NewTaskResult(ctx, handlerID, ...). The client then pollstasks/get, and can cancel withtasks/cancelor answer input withtasks/update.- FlexMCP stores nothing about a task. A
TaskHandleryou provide owns the work and its state. server.NewMemoryTasksis a ready-made in-memory handler:MemoryTasks.Runhands the call over when the request allows it, and otherwise runs the work synchronously.
- FlexMCP stores nothing about a task. A
- Unguessable task ids, bound to the caller. A task id is sealed with an HMAC, not looked up. Set
WithTaskKeyso ids survive a restart and work across instances, andWithTaskCallerso one caller cannot read another's tasks. - Client support.
GetExtensionTask,CancelExtensionTask,UpdateExtensionTaskandWaitForExtensionTask. A refused id is a typedmcp.TaskRefusedError;mcp.IsTaskGonetells you to call the tool again. - Both eras kept apart. The 2025-11-25 tasks (
AddTaskTool,params.task) serve initialize-era requests only. On a 2026-07-28 request,params.taskis ignored, task-only tools are hidden, andexecutionis dropped fromtools/list. - Works with Claude Code. Checked live against Claude Code 2.1.312, which declares the extension on its
tools/callandtasks/getand polls at the interval the server asks for. It does not declare it on every call, so a tool must still answer synchronously when no task is possible;MemoryTasks.Rundoes. - Documented and runnable. See Tasks and
examples/tasks_extension.
Changes you may notice
- The task result options are
WithTaskResultPollInterval,WithTaskResultTTL,WithTaskResultStatusMessageandWithTaskResultCreatedAt. TheWithTask*names already belong to the 2025-11-25 tasks. - Run handed-over work under
server.DetachTaskContext(ctx). It keeps the request's values and drops its cancellation, its session and its task stamp.MemoryTasks.Rundoes this for you. - On a 2026-07-28 request,
tasks/get,tasks/cancelandtasks/updatefire only the untyped hooks (BeforeAny,OnSuccess,OnError). The typed task hooks are for earlier revisions. - On a 2026-07-28 connection, the client's old
GetTask,CancelTask,WaitForTask,TaskResultandListTasksreturnErrLegacyTaskMethod. WithExtensionscopies its map. Given a tasks entry without a task handler, it panics at construction.- A client may leave without cancelling its task, so choose a TTL that bounds abandoned work.
MemoryTasksdefaults to one hour. mcp.WithModelImmediateResponseis deprecated. The server never sends it in the answer to a task-augmented call.
Fixes
- Output schema validation now judges a result's raw structured content when the result carries it. Before, raw content that broke the schema could be sent unchecked.
- A tool re-registered while a call is in flight:
- its
Mcp-Param-*header bindings are now enforced on that call; - a 2025-11-25 task-augmented call now runs the registration the tool filters authorized.
- its
- Tool filters on a 2026-07-28
tools/callsee the same tool thattools/listshowed them.
Known issues
- At a very small result-size limit, the answer that hands a call over can be replaced by a size error after the task has started. Keep the limit well above the size of a task answer.
Install
go get github.com/pbednarcik/flexmcp@v0.3.0The OpenTelemetry adapter is unchanged: github.com/pbednarcik/flexmcp/otel@v0.2.0.