Skip to main content
Glama

a2a_send_task_subscribe

Send a task to an A2A agent and subscribe to receive real-time streaming updates on its progress and responses.

Instructions

Send a task and subscribe to updates (streaming)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesMessage to send to the agent
taskIdNoOptional task ID. If not provided, a new UUID will be generated
agentIdNoOptional agent ID. If not provided, the first available agent will be used
maxUpdatesNoMaximum number of updates to receive (default: 10)

Implementation Reference

  • Handler for the 'a2a_send_task_subscribe' MCP tool. Selects an A2A client, sends a task with subscription for streaming updates, collects up to maxUpdates events, and returns the task ID and updates as JSON.
    case "a2a_send_task_subscribe": { const { message, taskId, agentId, maxUpdates = 10 } = args as { message: string; taskId?: string; agentId?: string; maxUpdates?: number; }; const client = agentId ? agentManager.getClientById(agentId) : agentManager.getAllClients().values().next().value; if (!client) { throw new Error(`No available agent${agentId ? ` with ID ${agentId}` : ''}`); } const id = taskId || crypto.randomUUID(); const stream = client.sendTaskSubscribe({ id, message: { role: "user", parts: [{ text: message }], }, }); const updates = []; let count = 0; for await (const event of stream) { updates.push(event); count++; if (count >= maxUpdates) break; if (event.final) break; } return { content: [ { type: "text", text: JSON.stringify({ taskId: id, updates }, null, 2), }, ], }; }
  • Input schema for the a2a_send_task_subscribe tool, validating message (required string), optional taskId, agentId, and maxUpdates (number).
    inputSchema: { type: "object", properties: { message: { type: "string", description: "Message to send to the agent", }, taskId: { type: "string", description: "Optional task ID. If not provided, a new UUID will be generated", }, agentId: { type: "string", description: "Optional agent ID. If not provided, the first available agent will be used", }, maxUpdates: { type: "number", description: "Maximum number of updates to receive (default: 10)", }, }, required: ["message"],
  • index.ts:91-116 (registration)
    Registration of the a2a_send_task_subscribe tool in the ListToolsRequestSchema response, including name, description, and input schema.
    { name: "a2a_send_task_subscribe", description: "Send a task and subscribe to updates (streaming)", inputSchema: { type: "object", properties: { message: { type: "string", description: "Message to send to the agent", }, taskId: { type: "string", description: "Optional task ID. If not provided, a new UUID will be generated", }, agentId: { type: "string", description: "Optional agent ID. If not provided, the first available agent will be used", }, maxUpdates: { type: "number", description: "Maximum number of updates to receive (default: 10)", }, }, required: ["message"], }, },
  • Supporting utility method A2AClient.sendTaskSubscribe that initiates the streaming JSON-RPC request to 'tasks/sendSubscribe' for real-time task updates.
    sendTaskSubscribe( params: TaskSendParams ): AsyncIterable<TaskStatusUpdateEvent | TaskArtifactUpdateEvent> { const streamGenerator = async function* ( this: A2AClient ): AsyncIterable<TaskStatusUpdateEvent | TaskArtifactUpdateEvent> { const httpResponse = await this._makeHttpRequest( "tasks/sendSubscribe", params, "text/event-stream" ); yield* this._handleStreamingResponse<TaskStatusUpdateEvent | TaskArtifactUpdateEvent>( httpResponse, "tasks/sendSubscribe" ); }.bind(this)(); return streamGenerator; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tesla0225/mcp-a2a'

If you have feedback or need assistance with the MCP directory API, please join our Discord server