neuroverse_route
Route tasks to downstream agents via HTTP by specifying target agent, task description, and payload for execution.
Instructions
Route a task to a registered downstream agent via HTTP.
Args:
target_agent (string): Name of the agent
task (string): Task description
payload (object): Arbitrary payload
Returns: JSON with the agent's response or a fallback error
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_agent | Yes | Name of the registered agent | |
| task | Yes | Task description to send | |
| payload | No | Arbitrary payload for the target |
Implementation Reference
- npm/src/index.ts:317-349 (handler)Tool registration and handler for 'neuroverse_route' in the MCP server.
server.registerTool( "neuroverse_route", { title: "Route to Agent", description: `Route a task to a registered downstream agent via HTTP. Args: - target_agent (string): Name of the agent - task (string): Task description - payload (object): Arbitrary payload Returns: JSON with the agent's response or a fallback error`, inputSchema: RouteAgentSchema, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true, }, }, async (params) => { const result = await routeToAgent({ targetAgent: params.target_agent, task: params.task, payload: params.payload as Record<string, unknown>, }); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } ); - npm/src/services/agent-router.ts:32-51 (handler)The core implementation of the routing logic that the 'neuroverse_route' tool calls.
export async function routeToAgent( request: AgentRoutingRequest ): Promise<Record<string, unknown>> { const agent = getAgent(request.targetAgent); if (!agent) { return { success: false, error: `Agent '${request.targetAgent}' is not registered.`, fallback: true }; } try { const resp = await axios.post( agent.endpoint, { task: request.task, payload: request.payload }, { headers: { "Content-Type": "application/json" }, timeout: 30000 } ); return { success: true, agent: request.targetAgent, response: resp.data }; } catch (e) { const msg = e instanceof Error ? e.message : String(e); return { success: false, error: `Agent unreachable: ${msg}`, fallback: true }; } } - npm/src/index.ts:306-315 (schema)Input schema definition for the 'neuroverse_route' tool.
const RouteAgentSchema = z .object({ target_agent: z.string().min(1).describe("Name of the registered agent"), task: z.string().min(1).describe("Task description to send"), payload: z .record(z.unknown()) .default({}) .describe("Arbitrary payload for the target"), }) .strict();