Mirror of https://github.com/modelcontextprotocol/ext-tasks — This repository provides a reference for the tasks extensions to the MCP protocol, allowing for long-running operations, such as Agent communication, in MCP.
  • TypeScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Luca Chang e4345978be
fix: make generated schema.json enforce spec constraints (#18)
The generated JSON Schema artifact previously failed to encode several
normative requirements, forcing non-TypeScript implementations to
maintain their own mirrors of core shapes and discriminators:

- InputRequest/InputResponse collapsed to anyOf:[{},{},{}] because the
  imported request/result types resolved to empty schemas, accepting
  any instance.
- The required resultType discriminators ('task' on CreateTaskResult,
  'complete' on Get/Update/CancelTaskResult) appeared nowhere in the
  artifact despite being normative MUSTs in the extension prose.
- Strip-mode object emission produced additionalProperties:false inside
  allOf intersections, making CreateTaskResult unsatisfiable: every
  spec-conformant instance (with resultType or _meta) was rejected.

The canonical specification is now the sole source of truth for all
core-spec shapes — no SDK package is consulted at any layer.
scripts/fetch-spec-schema.ts vendors spec.schema.json and spec.types.ts
from the same recorded spec commit with provenance headers:

- schema.ts imports every core type (JSON-RPC envelopes, Result,
  NotificationParams, the MRTR InputRequests/InputResponses, and the
  JSON-RPC Error object) from the vendored spec.types.ts, deleting the
  local mirrors that had already drifted from upstream.
- generate-schemas.ts emits $ref for all spec-owned types — including
  the JSON-RPC envelopes intersected by the extension's own types — and
  splices their transitive $ref closure verbatim from the vendored
  canonical schema.json. Core-spec corrections flow in via an explicit,
  reviewable refresh (npm run fetch:spec-schema) instead of silently
  diverging. The @modelcontextprotocol/sdk devDependency is removed.
- Runtime Zod stand-ins for imported types are permissive locals whose
  shapes never reach the artifact; generation fails on any unmapped
  placeholder, and on any definition that cannot be converted.
- JSON Schema emission uses io:'input' so TypeScript's open interface
  semantics are preserved and intersections remain satisfiable.
- resultType discriminators are encoded structurally in schema.ts.
- FailedTask.error now requires the canonical JSON-RPC Error shape;
  ttlMs and pollIntervalMs are integers per the prose.
- createdAt/lastUpdatedAt deliberately remain unconstrained strings:
  the prose requires ISO 8601 generally, and JSON Schema's date-time
  format/pattern machinery can only express RFC 3339, which would
  reject valid basic-form timestamps.

Validated with a Draft 2020-12 jsonschema matrix covering union
rejection/acceptance, discriminator enforcement, JSON-RPC envelope
enforcement, error-shape and integer constraints, byte-fidelity of all
56 spliced canonical definitions, complete $ref resolution, and
check-mode idempotency.
2026-08-21 13:44:01 -07:00
.github/workflows Set up Vitepress deployment (#7) 2026-06-09 12:18:41 -07:00
.vitepress Set up Vitepress deployment (#7) 2026-06-09 12:18:41 -07:00
public Set up Vitepress deployment (#7) 2026-06-09 12:18:41 -07:00
schema/draft fix: make generated schema.json enforce spec constraints (#18) 2026-08-21 13:44:01 -07:00
scripts fix: make generated schema.json enforce spec constraints (#18) 2026-08-21 13:44:01 -07:00
seps fix: correct MISSING_REQUIRED_CLIENT_CAPABILITY error code to -32021 (#10) 2026-08-19 19:30:36 -07:00
specification/draft fix: restore auth binding requirement to Security Considerations (#9) 2026-08-19 19:32:20 -07:00
.gitignore Set up Vitepress deployment (#7) 2026-06-09 12:18:41 -07:00
CODE_OF_CONDUCT.md first agentic pass 2026-05-11 14:25:28 -07:00
CONTRIBUTING.md Set up Vitepress deployment (#7) 2026-06-09 12:18:41 -07:00
index.md Set up Vitepress deployment (#7) 2026-06-09 12:18:41 -07:00
LICENSE first agentic pass 2026-05-11 14:25:28 -07:00
MAINTAINERS.md Update Tasks extension docs to reflect official MCP status (#13) 2026-08-19 19:21:58 -07:00
package-lock.json fix: make generated schema.json enforce spec constraints (#18) 2026-08-21 13:44:01 -07:00
package.json fix: make generated schema.json enforce spec constraints (#18) 2026-08-21 13:44:01 -07:00
README.md Update Tasks extension docs to reflect official MCP status (#13) 2026-08-19 19:21:58 -07:00
SECURITY.md first agentic pass 2026-05-11 14:25:28 -07:00
tsconfig.json generate schema with refs 2026-05-11 15:53:04 -07:00

MCP Tasks Extension

This repository contains the official Model Context Protocol Tasks extension (io.modelcontextprotocol/tasks), based on SEP-2663.

Overview

This extension defines the Tasks primitive for the Model Context Protocol (MCP). Tasks are durable state machines that carry information about the underlying execution state of a request, enabling requestor polling and deferred result retrieval. Each task is uniquely identifiable by a receiver-generated task ID.

Tasks are useful for:

  • Representing expensive computations and batch processing requests
  • Integrating seamlessly with external job/workflow APIs
  • Enabling call-now, fetch-later execution patterns

Extension Identifier: io.modelcontextprotocol/tasks

Development

Schema Generation

The JSON Schema is auto-generated from the TypeScript type definitions using ts-to-zod and Zod's toJSONSchema(). Do not hand-edit schema.json or generated/schema.ts.

# Generate Zod schemas and JSON Schema from schema.ts
npm run generate:schemas

# Verify TypeScript compiles and generated files are up to date
npm run check:schema

Governance

This repository follows the Model Context Protocol Governance process. See MAINTAINERS.md for the list of maintainers specific to this repository.

Policies

This repository follows the Model Context Protocol project policies:

License

This project is licensed under the Apache License 2.0. See LICENSE for details.