Skip to main content
Glama
nanoseil
by nanoseil

stop-background-task

Stop a running background task by its unique name to manage long-running processes like development servers or builds within MCP-compatible clients.

Instructions

Stops a running background task by its name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesUnique name of the task to stop

Implementation Reference

  • The main handler function for the 'stop-background-task' tool. It looks up the task by name in the processes Map, calls kill() on the Child instance if found, removes it from the map, and returns a text response.
    async ({ name }) => { const child = processes.get(name); if (!child) { return { content: [ { type: "text", text: `No task found with name "${name}".`, }, ], }; } child.kill(); processes.delete(name); return { content: [ { type: "text", text: `Task "${name}" has been stopped.`, }, ], }; }
  • The tool metadata and input schema definition, specifying title, description, and Zod schema for the 'name' parameter.
    { title: "Stop Background Task", description: "Stops a running background task by its name.", inputSchema: { name: z.string().describe("Unique name of the task to stop"), },
  • src/index.ts:105-139 (registration)
    The full registration of the 'stop-background-task' tool using McpServer.registerTool, including name, schema, and inline handler function.
    server.registerTool( "stop-background-task", { title: "Stop Background Task", description: "Stops a running background task by its name.", inputSchema: { name: z.string().describe("Unique name of the task to stop"), }, }, async ({ name }) => { const child = processes.get(name); if (!child) { return { content: [ { type: "text", text: `No task found with name "${name}".`, }, ], }; } child.kill(); processes.delete(name); return { content: [ { type: "text", text: `Task "${name}" has been stopped.`, }, ], }; } );
  • The kill() method in the Child class that terminates the child process using process.kill() and updates the state to 'stopped'. This is called by the tool handler.
    public kill(): void { if (this.process.killed) { return; } this.process.kill(); this.state = "stopped"; }

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