fal-cancel
Cancel a specific AI generation request using its request ID and model ID to stop processing.
Instructions
Cancel a the given request
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| requestId | Yes | ||
| modelId | Yes |
Implementation Reference
- src/tools/index.ts:116-124 (registration)Registration of the 'fal-cancel' tool on the McpServer with schema {requestId: string, modelId: string} and handler that calls client.cancel()
server.tool( 'fal-cancel', 'Cancel a the given request', { requestId: z.string(), modelId: z.string() }, async ({ requestId, modelId }) => { const output = await client.cancel(requestId, modelId); return { content: [{ type: 'text', text: toText(output) }] }; }, ); - src/tools/index.ts:120-123 (handler)Handler function for fal-cancel: receives requestId and modelId, calls client.cancel(requestId, modelId), returns text content
async ({ requestId, modelId }) => { const output = await client.cancel(requestId, modelId); return { content: [{ type: 'text', text: toText(output) }] }; }, - src/tools/index.ts:119-119 (schema)Input schema for fal-cancel: requestId (string) and modelId (string), validated with zod
{ requestId: z.string(), modelId: z.string() }, - src/services/fal-client.ts:80-93 (helper)FalClient.cancel() method: constructs URL using QUEUE_BASE, sends PUT request with API key auth, handles errors and parses response
async cancel(requestId: string, modelId: string): Promise<unknown> { const baseModel = this._baseModelId(this._normalizeModelId(modelId)); const url = `${this.QUEUE_BASE}/${baseModel}/requests/${encodeURIComponent(requestId)}/cancel`; const res = await request(url, { method: 'PUT', headers: { Authorization: `Key ${this._apiKey}`, }, }); if (res.statusCode && res.statusCode >= 400) { await this._throwForStatus(res.statusCode, url, await res.body.text()); } return await this._safeParse(await res.body.text()); }