Skip to main content
Glama
suthio

Redash MCP Server

by suthio

create_query_snippet

Create a reusable SQL snippet by defining a trigger keyword and content, enabling quick insertion of common query parts.

Instructions

Create a new reusable query snippet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
triggerYesTrigger keyword for the snippet
descriptionNoDescription of the snippet
snippetYesThe SQL snippet content

Implementation Reference

  • The main handler function for the create_query_snippet tool. It validates input using createQuerySnippetSchema, constructs a CreateQuerySnippetRequest, calls redashClient.createQuerySnippet(), and returns the result as JSON text content.
    async function createQuerySnippet(params: z.infer<typeof createQuerySnippetSchema>) {
      try {
        const snippetData: CreateQuerySnippetRequest = {
          trigger: params.trigger,
          description: params.description,
          snippet: params.snippet
        };
        const result = await redashClient.createQuerySnippet(snippetData);
        return {
          content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
        };
      } catch (error) {
        logger.error(`Error creating query snippet: ${error}`);
        return {
          isError: true,
          content: [{ type: "text", text: `Error creating query snippet: ${error instanceof Error ? error.message : String(error)}` }]
        };
      }
    }
  • Zod schema for create_query_snippet input validation. Defines required fields: trigger (string) and snippet (string), plus optional description (string).
    const createQuerySnippetSchema = z.object({
      trigger: z.string(),
      description: z.string().optional(),
      snippet: z.string()
    });
  • src/index.ts:2242-2254 (registration)
    Registration of create_query_snippet in the ListToolsRequestSchema handler. Defines the tool name, description, and inputSchema for the MCP protocol.
    {
      name: "create_query_snippet",
      description: "Create a new reusable query snippet",
      inputSchema: {
        type: "object",
        properties: {
          trigger: { type: "string", description: "Trigger keyword for the snippet" },
          description: { type: "string", description: "Description of the snippet" },
          snippet: { type: "string", description: "The SQL snippet content" }
        },
        required: ["trigger", "snippet"]
      }
    },
  • The Redash API client method that makes the HTTP POST request to /api/query_snippets to create a query snippet. Accepts CreateQuerySnippetRequest data and returns a RedashQuerySnippet.
    async createQuerySnippet(data: CreateQuerySnippetRequest): Promise<RedashQuerySnippet> {
      try {
        const response = await this.client.post('/api/query_snippets', data);
        return response.data;
      } catch (error) {
        logger.error(`Error creating query snippet: ${error}`);
        throw new Error(`Failed to create query snippet: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:2542-2544 (registration)
    Dispatch routing in CallToolRequestSchema handler for create_query_snippet. Routes the 'create_query_snippet' tool call to the createQuerySnippet handler function with schema validation.
    case "create_query_snippet":
      logger.debug(`Handling create_query_snippet`);
      return await createQuerySnippet(createQuerySnippetSchema.parse(args));
Behavior3/5

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

Annotations are absent, so description must convey behavioral traits. It only says 'create', which implies a mutation, but does not disclose side effects, permissions, or immediate availability. Minimal but not misleading.

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?

Single sentence, front-loaded, no unnecessary words. Perfectly concise.

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

Completeness4/5

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

For a simple creation tool with well-documented parameters, the description is sufficient. Lacks only minor context like return behavior or typical usage scenarios.

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 description coverage is 100%, so baseline is 3. Description adds no additional meaning beyond the parameter descriptions.

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?

Description clearly states 'Create a new reusable query snippet', specifying the verb and resource. It distinguishes from sibling tools like update_query_snippet and delete_query_snippet.

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 guidance on when to use this tool versus alternatives (e.g., update_query_snippet). No prerequisites or context provided.

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