Skip to main content
Task sessions are short-lived tokens that connect an agent’s identity to a specific task. They carry context (like a customer ID or ticket number) that policies can reference to scope access.

Create a task session

Request body: Response:

Use a task session

Include the task token in subsequent MCP requests using the X-Task-Token header alongside your Authorization header:
In the MCP Inspector, add both headers before connecting. MCP clients and SDKs include these headers in the transport configuration. The gateway resolves the task session and makes the task context available during policy evaluation.

Get the current session

Returns the active session details including the task name, context, and expiry time.

Delete a session

End a task session early when the agent finishes its work:
This immediately invalidates the task token. Any subsequent requests using it will be rejected.
Always delete task sessions when the agent finishes a task. This follows the principle of least privilege — don’t keep access open longer than needed.

Lifecycle

Context validation

When you create a task session, the gateway validates the context field against the task’s JSON Schema. If the context doesn’t match, the session is rejected with a 400 error.

Notes

  • An agent can have multiple active task sessions simultaneously
  • Task sessions are tied to both the identity and the task definition
  • The maximum TTL is 24 hours to prevent long-lived access tokens
  • Both the bearer token and task token must be valid for a request to succeed