send_to_agent
Send text input to AI agents in terminal multiplexer workspaces. Use this tool to provide commands or queries to agents that are ready or idle for processing.
Instructions
Send text input to an agent. Agent must be in ready or idle state.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | Agent ID | |
| text | Yes | Text to send | |
| press_enter | No | Press enter after sending text |
Implementation Reference
- src/agent-engine.ts:586-607 (handler)The main implementation of the `sendToAgent` method that interacts with the agent client.
async sendToAgent( agentId: string, text: string, pressEnter?: boolean, ): Promise<void> { const agent = this.registry.get(agentId); if (!agent) { throw new Error(`Agent not found: ${agentId}`); } if (!INTERACTIVE_STATES.has(agent.state)) { throw new Error( `Agent "${agentId}" is not in an interactive state (current: ${agent.state}). ` + `Must be in: ${[...INTERACTIVE_STATES].join(", ")}`, ); } await this.client.send(agent.surface_id, text, {}); if (pressEnter) { await this.client.sendKey(agent.surface_id, "return", {}); } } - src/server.ts:862-880 (registration)The MCP tool registration for `send_to_agent`, which calls the `engine.sendToAgent` handler.
server.tool( "send_to_agent", "Send text input to an agent. Agent must be in ready or idle state.", { agent_id: z.string().describe("Agent ID"), text: z.string().describe("Text to send"), press_enter: z .boolean() .optional() .default(true) .describe("Press enter after sending text"), }, async (args) => { try { await engine.sendToAgent(args.agent_id, args.text, args.press_enter); return ok({ agent_id: args.agent_id, applied: "send_to_agent", });