Skip to main content
Glama
nanoseil
by nanoseil

send-to-task-stdin

Send input data directly to the standard input of an active background task managed by the MCP server, enabling dynamic interaction with long-running processes.

Instructions

Sends data to the stdin of a running background task.

Input Schema

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

Implementation Reference

  • Handler function that retrieves the background task by name and sends the provided data to its stdin via child.writeToStdin, handling errors and returning appropriate responses.
    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) }`, }, ], }; } }
  • Input schema definition for the tool, specifying 'name' and 'data' parameters using Zod.
    { 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)
    Registration of the 'send-to-task-stdin' tool on the MCP server with title, description, input 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) }`, }, ], }; } } );
  • Helper method in the Child class that writes data to the child process's stdin, throwing an error if stdin is not available.
    public writeToStdin(data: string): void { if (this.process.stdin) { this.process.stdin.write(data); } else { throw new Error("Child process stdin is not available."); }

Other Tools

Related Tools

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