Skip to main content
Glama

Cancel Simulation

cancel_simulation
Destructive

Stop a running simulation immediately, preserving partial data for review. Use when simulations take too long, were started by mistake, or produce unwanted output.

Instructions

Stop a running simulation. SIGTERMs the subprocess immediately and marks the simulation as stopped. Partial action log is preserved — you can still call get_report or simulation_data on a cancelled simulation for whatever data was produced before cancellation. Use this when a simulation is taking too long, was started by mistake, or is producing bad output you want to abort.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
simulation_idYesThe simulation ID to cancel

Implementation Reference

  • The async handler function that executes the cancel_simulation tool logic. Calls client.cancelSimulation(), formats the response with simulation snapshot data (state, actions count, completed_at).
    async (args) => {
      try {
        const snapshot = await client.cancelSimulation(args.simulation_id);
        const total =
          snapshot.twitter_actions_count + snapshot.reddit_actions_count;
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  simulation_id: snapshot.simulation_id,
                  state: snapshot.state,
                  twitter_actions_count: snapshot.twitter_actions_count,
                  reddit_actions_count: snapshot.reddit_actions_count,
                  total_actions: total,
                  completed_at: snapshot.completed_at,
                  message:
                    `Simulation ${args.simulation_id} cancelled. ` +
                    `${total} actions were captured before termination.`,
                },
                null,
                2,
              ),
            },
          ],
        };
      } catch (err) {
        throw toMcpError(err);
      }
    },
  • Input schema for cancel_simulation: requires a simulation_id string.
    const inputSchema = {
      simulation_id: z.string().describe("The simulation ID to cancel"),
    };
  • The registerCancelSimulation function that registers the tool with name 'cancel_simulation' on the MCP server, including title, description, input schema, and annotations.
    export function registerCancelSimulation(server: McpServer, client: MirofishClient): void {
      server.registerTool(
        "cancel_simulation",
        {
          title: "Cancel Simulation",
          description:
            "Stop a running simulation. SIGTERMs the subprocess immediately and marks " +
            "the simulation as stopped. Partial action log is preserved — you can still " +
            "call get_report or simulation_data on a cancelled simulation for whatever " +
            "data was produced before cancellation. Use this when a simulation is taking " +
            "too long, was started by mistake, or is producing bad output you want to abort.",
          inputSchema,
          annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
        },
        async (args) => {
          try {
            const snapshot = await client.cancelSimulation(args.simulation_id);
            const total =
              snapshot.twitter_actions_count + snapshot.reddit_actions_count;
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      simulation_id: snapshot.simulation_id,
                      state: snapshot.state,
                      twitter_actions_count: snapshot.twitter_actions_count,
                      reddit_actions_count: snapshot.reddit_actions_count,
                      total_actions: total,
                      completed_at: snapshot.completed_at,
                      message:
                        `Simulation ${args.simulation_id} cancelled. ` +
                        `${total} actions were captured before termination.`,
                    },
                    null,
                    2,
                  ),
                },
              ],
            };
          } catch (err) {
            throw toMcpError(err);
          }
        },
      );
    }
  • Registration import and call in the central tools index. Imports registerCancelSimulation and calls it in registerAllTools.
    import { registerCancelSimulation } from "./cancel-simulation.js";
    
    export function registerAllTools(server: McpServer, client: MirofishClient): void {
      registerCreateSimulation(server, client);
      registerSimulationStatus(server, client);
      registerGetReport(server, client);
      registerInterviewAgent(server, client);
      registerListSimulations(server, client);
      registerSearchSimulations(server, client);
      registerUploadDocument(server, client);
      registerSimulationData(server, client);
      registerCancelSimulation(server, client);
    }
  • The client-side helper that makes the HTTP POST request to /api/simulation/{simulationId}/cancel to cancel a simulation on the backend.
    async cancelSimulation(simulationId: string): Promise<SimSnapshot> {
      const resp = await this.http.post<MirofishApiResponse<SimSnapshot>>(
        `/api/simulation/${simulationId}/cancel`,
      );
      if (resp.status === 404 || !resp.data?.data) {
        throw new SimulationNotFoundError(simulationId);
      }
      return resp.data.data;
    }
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Describes internal behavior (SIGTERM, marking as stopped) and post-cancellation state (partial log preserved, ability to query data). Complements annotations (destructiveHint=true) without contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, no fluff, front-loaded with core action. Every sentence adds value: what, how, when.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and no output schema, the description fully covers needed information: effect, post-cancellation behavior, and usage guidance.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a clear parameter description. The tool description does not add extra meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Stop a running simulation' and explains the mechanism and effect, distinguishing it from sibling tools like create_simulation or list_simulations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides three use cases: 'when a simulation is taking too long, was started by mistake, or is producing bad output you want to abort.' No ambiguity about when to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/kakarot-dev/deepmiro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server