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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Unique name of the task | |
| data | Yes | Data to send to the task's stdin |
Implementation Reference
- src/index.ts:261-297 (handler)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) }`, }, ], }; } } );
- src/index.ts:253-260 (schema)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) }`, }, ], }; } } );
- src/index.ts:49-55 (helper)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."); } }