fork_query
Create a copy of an existing Redash query by specifying its ID. This allows you to modify the duplicate without altering the original.
Instructions
Fork (duplicate) an existing query
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| queryId | Yes | ID of the query to fork |
Implementation Reference
- src/index.ts:1131-1144 (handler)MCP tool handler function for fork_query - receives queryId, calls redashClient.forkQuery(), and returns result as JSON text content.
async function forkQuery(params: z.infer<typeof forkQuerySchema>) { try { const result = await redashClient.forkQuery(params.queryId); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error(`Error forking query ${params.queryId}: ${error}`); return { isError: true, content: [{ type: "text", text: `Error forking query ${params.queryId}: ${error instanceof Error ? error.message : String(error)}` }] }; } } - src/index.ts:1127-1129 (schema)Zod validation schema for fork_query - expects a single numeric queryId parameter.
const forkQuerySchema = z.object({ queryId: z.coerce.number() }); - src/index.ts:2087-2097 (registration)MCP tool registration listing fork_query in the tools array returned by ListToolsRequestSchema handler.
{ name: "fork_query", description: "Fork (duplicate) an existing query", inputSchema: { type: "object", properties: { queryId: { type: "number", description: "ID of the query to fork" } }, required: ["queryId"] } }, - src/index.ts:2484-2486 (registration)CallToolRequestSchema switch-case dispatching to forkQuery handler when tool name is 'fork_query'.
case "fork_query": logger.debug(`Handling fork_query`); return await forkQuery(forkQuerySchema.parse(args)); - src/redashClient.ts:1008-1016 (helper)RedashClient.forkQuery helper method - makes POST request to /api/queries/{queryId}/fork to fork a query via the Redash API.
async forkQuery(queryId: number): Promise<RedashQuery> { try { const response = await this.client.post(`/api/queries/${queryId}/fork`); return response.data; } catch (error) { logger.error(`Error forking query ${queryId}: ${error}`); throw new Error(`Failed to fork query ${queryId}: ${error instanceof Error ? error.message : String(error)}`); } }