Skip to main content
Glama

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
NameRequiredDescriptionDefault
agent_idYesAgent ID
textYesText to send
press_enterNoPress enter after sending text

Implementation Reference

  • 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",
          });

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/EtanHey/cmuxlayer'

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