a2a_send_task
Send tasks to A2A agents using this tool, facilitating message delivery and task tracking. Supports custom task IDs or auto-generates them, and routes tasks to specified or available agents.
Instructions
Send a task to an A2A agent
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agentId | No | Optional agent ID. If not provided, the first available agent will be used | |
| message | Yes | Message to send to the agent | |
| taskId | No | Optional task ID. If not provided, a new UUID will be generated |
Implementation Reference
- index.ts:33-54 (registration)Registration of the a2a_send_task tool in the MCP server's listTools handler, including name, description, and input schema definition.{ name: "a2a_send_task", description: "Send a task to an A2A agent", 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", }, }, required: ["message"], }, },
- index.ts:139-162 (handler)Handler logic for executing the a2a_send_task tool: parses arguments, selects A2A client, calls sendTask, returns result as text content.case "a2a_send_task": { const { message, taskId, agentId } = args as { message: string; taskId?: string; agentId?: string }; const client = agentId ? agentManager.getClientById(agentId) : agentManager.getAllClients().values().next().value; if (!client) { throw new Error(`No available agent${agentId ? ` with ID ${agentId}` : ''}`); } const result = await client.sendTask({ id: taskId || crypto.randomUUID(), message: { role: "user", parts: [{ text: message }], }, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- a2a-client.ts:383-386 (helper)Core helper method in A2AClient that implements the task sending by making a JSON-RPC POST request to the A2A agent's 'tasks/send' endpoint.async sendTask(params: TaskSendParams): Promise<Task | null> { const httpResponse = await this._makeHttpRequest("tasks/send", params); return this._handleJsonResponse<Task | null>(httpResponse, "tasks/send"); }
- agent-manager.ts:29-31 (helper)AgentManager method to retrieve the A2AClient instance by agent ID, used in the tool handler.getClientById(id: string): A2AClient | undefined { return this.clients.get(id); }