Skip to main content
Glama

execute-prepared-query

Run predefined queries on the Consul MCP Server to retrieve specific data or configurations using a query ID. Streamlines access to Consul services, health checks, KV stores, and more.

Instructions

Execute a prepared query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoID of the prepared query

Implementation Reference

  • The core handler function for the 'execute-prepared-query' tool. It takes the prepared query ID, executes it via consul.query.execute(id), stringifies the results, and returns them in the MCP content format. Includes error handling.
    async ({ id }) => { try { // @ts-ignore - The Consul type definitions are incomplete const results = await consul.query.execute(id); return { content: [{ type: "text", text: `Query results:\n\n${JSON.stringify(results, null, 2)}` }] }; } catch (error) { console.error("Error executing prepared query:", error); return { content: [{ type: "text", text: `Error executing prepared query: ${id}` }] }; } }
  • Zod input schema defining the 'id' parameter as a required string for the prepared query ID.
    { id: z.string().default("").describe("ID of the prepared query"), },
  • Registration of the 'execute-prepared-query' tool on the MCP server within the registerPreparedQueryTools function, including name, description, input schema, and inline handler.
    server.tool( "execute-prepared-query", "Execute a prepared query", { id: z.string().default("").describe("ID of the prepared query"), }, async ({ id }) => { try { // @ts-ignore - The Consul type definitions are incomplete const results = await consul.query.execute(id); return { content: [{ type: "text", text: `Query results:\n\n${JSON.stringify(results, null, 2)}` }] }; } catch (error) { console.error("Error executing prepared query:", error); return { content: [{ type: "text", text: `Error executing prepared query: ${id}` }] }; } } );

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/kocierik/consul-mcp-server'

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