Cancel Simulation
cancel_simulationStop 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
| Name | Required | Description | Default |
|---|---|---|---|
| simulation_id | Yes | The 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"), }; - mcp-server/src/tools/cancel-simulation.ts:13-59 (registration)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); } }, ); } - mcp-server/src/tools/index.ts:14-26 (registration)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; }