Skip to main content
Glama
suthio

Redash MCP Server

by suthio

update_query

Update an existing query in Redash by providing its ID and optionally modifying the SQL, name, data source, schedule, tags, or other properties.

Instructions

Update an existing query in Redash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryIdYesID of the query to update
nameNoNew name of the query
data_source_idNoID of the data source to use
queryNoSQL query text
descriptionNoDescription of the query
optionsNoQuery options
scheduleNoQuery schedule
tagsNoTags for the query
is_archivedNoWhether the query is archived
is_draftNoWhether the query is a draft

Implementation Reference

  • The main handler function for the 'update_query' tool. Extracts queryId and updateData from params, builds an UpdateQueryRequest with only non-undefined fields, then calls redashClient.updateQuery().
    async function updateQuery(params: z.infer<typeof updateQuerySchema>) {
      try {
        const { queryId, ...updateData } = params;
    
        logger.debug(`Update query ${queryId} params: ${JSON.stringify(updateData)}`);
    
        // Convert params to UpdateQueryRequest - only include non-undefined fields
        const queryData: UpdateQueryRequest = {};
    
        // Only add fields that are defined
        if (updateData.name !== undefined) queryData.name = updateData.name;
        if (updateData.data_source_id !== undefined) queryData.data_source_id = updateData.data_source_id;
        if (updateData.query !== undefined) queryData.query = updateData.query;
        if (updateData.description !== undefined) queryData.description = updateData.description;
        if (updateData.options !== undefined) queryData.options = updateData.options;
        if (updateData.schedule !== undefined) queryData.schedule = updateData.schedule;
        if (updateData.tags !== undefined) queryData.tags = updateData.tags;
        if (updateData.is_archived !== undefined) queryData.is_archived = updateData.is_archived;
        if (updateData.is_draft !== undefined) queryData.is_draft = updateData.is_draft;
    
        logger.debug(`Calling redashClient.updateQuery with data: ${JSON.stringify(queryData)}`);
        const result = await redashClient.updateQuery(queryId, queryData);
        logger.debug(`Update query result: ${JSON.stringify(result)}`);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2)
            }
          ]
        };
      } catch (error) {
        logger.error(`Error updating query ${params.queryId}: ${error instanceof Error ? error.message : String(error)}`);
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error updating query ${params.queryId}: ${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
    }
  • Zod schema for the 'update_query' tool input validation. Defines queryId (required, number), and optional fields: name, data_source_id, query, description, options, schedule, tags, is_archived, is_draft.
    // Tool: update_query
    const updateQuerySchema = z.object({
      queryId: z.coerce.number(),
      name: z.string().optional(),
      data_source_id: z.coerce.number().optional(),
      query: z.string().optional(),
      description: z.string().optional(),
      options: z.any().optional(),
      schedule: z.any().optional(),
      tags: z.array(z.string()).optional(),
      is_archived: z.boolean().optional(),
      is_draft: z.boolean().optional()
    });
  • src/index.ts:1645-1664 (registration)
    Registration of the 'update_query' tool in the ListToolsRequestSchema handler, including name, description, and inputSchema definition with all properties and their types/descriptions.
    {
      name: "update_query",
      description: "Update an existing query in Redash",
      inputSchema: {
        type: "object",
        properties: {
          queryId: { type: "number", description: "ID of the query to update" },
          name: { type: "string", description: "New name of the query" },
          data_source_id: { type: "number", description: "ID of the data source to use" },
          query: { type: "string", description: "SQL query text" },
          description: { type: "string", description: "Description of the query" },
          options: { type: "object", description: "Query options" },
          schedule: { type: "object", description: "Query schedule" },
          tags: { type: "array", items: { type: "string" }, description: "Tags for the query" },
          is_archived: { type: "boolean", description: "Whether the query is archived" },
          is_draft: { type: "boolean", description: "Whether the query is a draft" }
        },
        required: ["queryId"]
      }
    },
  • src/index.ts:2318-2334 (registration)
    Routing logic in CallToolRequestSchema handler that dispatches 'update_query' tool calls to the updateQuery handler with schema validation.
    } else if (name === "update_query") {
      try {
        logger.debug(`Validating update_query schema`);
        const validatedArgs = updateQuerySchema.parse(args);
        logger.debug(`Schema validation passed for update_query: ${JSON.stringify(validatedArgs)}`);
        return await updateQuery(validatedArgs);
      } catch (validationError) {
        logger.error(`Schema validation failed for update_query: ${validationError}`);
        return {
          isError: true,
          content: [{
            type: "text",
            text: `Invalid parameters for update_query: ${validationError instanceof Error ? validationError.message : String(validationError)}`
          }]
        };
      }
    }
  • The UpdateQueryRequest TypeScript interface defining all optional fields that can be sent to the Redash API when updating a query: name, data_source_id, query, description, options, schedule, tags, is_archived, is_draft.
    export interface UpdateQueryRequest {
      name?: string;
      data_source_id?: number;
      query?: string;
      description?: string;
      options?: any;
      schedule?: any;
      tags?: string[];
      is_archived?: boolean;
      is_draft?: boolean;
    }
Behavior2/5

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

No annotations are present, so the description carries full burden. It only states 'Update', implying mutation, but gives no details on idempotency, error behavior (e.g., missing queryId), or side effects. The behavioral traits are under-disclosed.

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

Conciseness4/5

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

The description is a single concise sentence with no wasted words. However, it lacks structure (e.g., bullet points or sections) that could improve readability for a tool with many parameters. Still, it earns a high score for brevity.

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

Completeness2/5

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

Given the tool's complexity (10 parameters, no output schema, no annotations), the description is inadequate. It omits return values, prerequisites, and behavior for optional fields. The description needs to cover more contextual details to be complete.

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?

The input schema has 100% description coverage for all 10 parameters, so baseline is 3. The description adds no additional parameter meaning beyond the schema's brief descriptions, but does not detract. Schema already provides sufficient parameter semantics.

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

Purpose4/5

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

The description clearly states the action 'Update' and the resource 'an existing query in Redash', distinguishing it from sibling tools like create_query or archive_query. However, it lacks differentiation from other update tools (e.g., update_alert) and does not specify which fields can be updated, limiting its clarity.

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

Usage Guidelines2/5

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

No usage guidelines are provided. The description does not indicate when to use this tool versus create_query or archive_query, nor does it mention that queryId is required or that other parameters are optional. The agent receives no context for decision-making.

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/suthio/redash-mcp'

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