Skip to main content
Glama
nanoseil
by nanoseil

send-to-task-stdin

Send input data to running background tasks for interactive communication with long-running processes like development servers or builds.

Instructions

Sends data to the stdin of a running background task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesUnique name of the task
dataYesData to send to the task's stdin

Implementation Reference

  • The handler function for the 'send-to-task-stdin' tool. It retrieves the Child process by task name from the processes Map, and calls writeToStdin(data) on it, returning success or error message.
    async ({ name, data }) => { const child = processes.get(name); if (!child) { return { content: [ { type: "text", text: `No task found with name "${name}".`, }, ], }; } try { child.writeToStdin(data); return { content: [ { type: "text", text: `Data sent to task "${name}" stdin.`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to send data to task "${name}" stdin: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • The schema definition for the 'send-to-task-stdin' tool, including title, description, and inputSchema using Zod for name and data parameters.
    { title: "Send to Task Stdin", description: "Sends data to the stdin of a running background task.", inputSchema: { name: z.string().describe("Unique name of the task"), data: z.string().describe("Data to send to the task's stdin"), }, },
  • src/index.ts:251-297 (registration)
    The server.registerTool call that registers the 'send-to-task-stdin' tool with its schema and handler function.
    server.registerTool( "send-to-task-stdin", { title: "Send to Task Stdin", description: "Sends data to the stdin of a running background task.", inputSchema: { name: z.string().describe("Unique name of the task"), data: z.string().describe("Data to send to the task's stdin"), }, }, async ({ name, data }) => { const child = processes.get(name); if (!child) { return { content: [ { type: "text", text: `No task found with name "${name}".`, }, ], }; } try { child.writeToStdin(data); return { content: [ { type: "text", text: `Data sent to task "${name}" stdin.`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to send data to task "${name}" stdin: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
  • The writeToStdin method in the Child class, which performs the actual writing to the child process's stdin using Node.js child_process.stdin.write.
    public writeToStdin(data: string): void { if (this.process.stdin) { this.process.stdin.write(data); } else { throw new Error("Child process stdin is not available."); } }

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/nanoseil/mcp-bgtask'

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