DS DevShelfHub Projects · AI tools
Tutorials / MCP / Reference / Methods / tasks/get
Method Requestor → Receiver

tasks/get

By DevShelfHub

Poll for the current status of a Task.

What it does

tasks/get is a poll-based query method sent from a Requestor to a Receiver to retrieve the latest state snapshot of a named Task. The Requestor supplies a single taskId string in the params object; the Receiver responds with a full Task object containing the current status, an optional statusMessage, ISO 8601 timestamps (createdAt, lastUpdatedAt), a ttl in milliseconds, and a pollInterval hint. The method follows standard JSON-RPC 2.0 framing and requires a correlating id field so the response can be matched to the request.

Before calling tasks/get, both sides must have successfully negotiated tasks capability during initialize. The Requestor declares tasks support in its ClientCapabilities and the Receiver advertises it in ServerCapabilities; if either side omits the capability, calls to tasks/get are undefined behavior and most implementations return -32601 (method not found). The method has no pagination — it always returns the single Task identified by taskId in one round trip.

Error handling requires particular care. If the Receiver has already purged the task after its ttl elapsed, it returns JSON-RPC error -32602 with a message such as "Task has expired" — callers must treat this as a non-retryable terminal condition and discard the taskId. If the taskId was never known, -32602 is also correct. When status reaches a terminal value (completed, failed, or cancelled), callers should stop polling and — if the status is completed — follow up with tasks/result to retrieve the actual payload. Calling tasks/get after a terminal status is harmless but wastes a round trip once the ttl window closes.

When to use

On the recommended pollInterval for working tasks.

When NOT to use

Faster than pollInterval suggests.

Notes

Capability negotiation is mandatory

Both the Requestor's ClientCapabilities and the Receiver's ServerCapabilities must include a tasks object from initialize before any tasks/* method is legal. Attempting tasks/get without capability advertisement typically results in a -32601 (Method not found) error rather than a graceful degradation, so check negotiated capabilities before making the call.

Respect the pollInterval field

The Task object returned by tasks/get includes a pollInterval in milliseconds that the Receiver sets based on its expected workload. Polling faster than this hint risks triggering per-client rate limiting or receiving -32429 (Too Many Requests) errors on conformant servers. Use the returned pollInterval value, not a hardcoded constant, and update it on each response since the server may raise or lower it dynamically.

Expired tasks return -32602, not a status field

Once a Task's ttl expires post-completion the Receiver is permitted to purge it entirely. A subsequent tasks/get will not return a Task with status 'expired' — it will return a JSON-RPC error object with code -32602. Your polling loop must catch this error code and treat it as a terminal signal equivalent to cancelled, discarding the taskId and surfacing an appropriate message to the user.

Stop polling at terminal statuses

The five TaskStatus values fall into two groups: non-terminal (working, input_required) and terminal (completed, failed, cancelled). Once tasks/get returns a terminal status, no further polling is necessary. If status is completed, immediately call tasks/result to retrieve the payload before the ttl window closes. Continuing to poll after a terminal state wastes network round trips and accelerates ttl expiry.

Race condition between ttl and result retrieval

There is an inherent race between the task completing, tasks/get returning status 'completed', and the client calling tasks/result before the ttl elapses. On slow or congested transports this window can be tight. Design your polling loop to call tasks/result in the same event-loop tick (or synchronous callback) that processes a completed status from tasks/get, rather than deferring it to the next poll cycle.

Request parameters

NameTypePurpose
taskIdstringTask identifier.

Response fields

NameTypePurpose
taskTaskCurrent state.

Examples

Poll task

json
{ "method": "tasks/get", "params": { "taskId": "abc" } }

Common mistakes

❌ Polling faster than pollInterval

✅ Honour the hint to avoid rate limits.

Related

tasks/get FAQ

What does the tasks/get method do in MCP?

tasks/get is an MCP JSON-RPC 2.0 method used for structured communication between MCP clients and servers. It is part of the Model Context Protocol message layer.

Who calls tasks/get in an MCP session?

tasks/get is called by the Requestor → Receiver. Refer to the capability negotiation docs to confirm the required capabilities.

What request type does tasks/get use?

See the Request Parameters section on this page for the request type and fields accepted by tasks/get. All MCP method requests use JSON-RPC 2.0 format with an id field for correlation.

What does tasks/get return?

See the Result section on this page for the response type returned by tasks/get. Errors are returned as JSON-RPC 2.0 error objects with a code and message.

Where can I find more MCP method documentation?

The complete MCP API reference on DevShelfHub documents all JSON-RPC methods with request/result types, examples, and common mistakes. Visit the MCP API Reference index to browse all methods.