get-task-stdout
Retrieve the standard output (stdout) of a running background task by specifying its unique name, enabling real-time monitoring and debugging within the MCP Background Task Server.
Instructions
Retrieves the stdout of a running background task.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Unique name of the task |
Implementation Reference
- src/index.ts:181-214 (registration)Registers the 'get-task-stdout' MCP tool with server.registerTool, providing the tool name, schema (title, description, inputSchema), and handler function.server.registerTool( "get-task-stdout", { title: "Get Task Stdout", description: "Retrieves the stdout of a running background task.", inputSchema: { name: z.string().describe("Unique name of the task"), }, }, async ({ name }) => { const child = processes.get(name); if (!child) { return { content: [ { type: "text", text: `No task found with name "${name}".`, }, ], }; } return { content: [ { type: "text", text: `Stdout of task "${name}":\n${ child.stdout || "No output yet." }`, }, ], }; } );
- src/index.ts:190-213 (handler)Handler function that retrieves the Child process instance by task name from the global processes Map, checks if it exists, and returns a response containing the accumulated stdout or a no-task message.async ({ name }) => { const child = processes.get(name); if (!child) { return { content: [ { type: "text", text: `No task found with name "${name}".`, }, ], }; } return { content: [ { type: "text", text: `Stdout of task "${name}":\n${ child.stdout || "No output yet." }`, }, ], }; }
- src/index.ts:183-189 (schema)Tool schema definition including title, description, and Zod input schema requiring a single 'name' string parameter.{ title: "Get Task Stdout", description: "Retrieves the stdout of a running background task.", inputSchema: { name: z.string().describe("Unique name of the task"), }, },
- src/index.ts:34-36 (helper)Helper method on the Child class to retrieve the accumulated stdout string (though accessed directly in the handler).public getStdout(): string { return this.stdout; }
- src/index.ts:71-71 (helper)Global Map storing active background tasks by name, used to retrieve Child instance in the handler.const processes = new Map<string, Child>();