Skip to main content
Glama
nanoseil

MCP Background Task Server

by nanoseil

get-task-stderr

Retrieve stderr output from a running background task to monitor errors and debug processes in MCP server environments.

Instructions

Retrieves the stderr of a running background task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesUnique name of the task

Implementation Reference

  • Handler function that fetches the stderr output from the Child process instance for the given task name and returns it in the tool response format.
    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: `Stderr of task "${name}":\n${
              child.stderr || "No error output yet."
            }`,
          },
        ],
      };
    }
  • Schema definition for the get-task-stderr tool, including title, description, and input schema requiring a task name.
    {
      title: "Get Task Stderr",
      description: "Retrieves the stderr of a running background task.",
      inputSchema: {
        name: z.string().describe("Unique name of the task"),
      },
    },
  • src/index.ts:216-249 (registration)
    Registration of the get-task-stderr tool with the MCP server, including schema and handler.
    server.registerTool(
      "get-task-stderr",
      {
        title: "Get Task Stderr",
        description: "Retrieves the stderr 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: `Stderr of task "${name}":\n${
                child.stderr || "No error output yet."
              }`,
            },
          ],
        };
      }
    );
  • Event listener that accumulates stderr output from the child process into the Child instance's stderr property.
    child.stderr?.on("data", (data) => {
      this.stderr += data.toString();
    });
  • Getter method for accessing the accumulated stderr of a Child process instance.
    public getStderr(): string {
      return this.stderr;

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