Skip to main content
Glama

prom_instant_query

Execute PromQL instant queries to retrieve current metric values from Prometheus monitoring systems for infrastructure analysis and troubleshooting.

Instructions

Execute a PromQL instant query and return current values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPromQL query expression

Implementation Reference

  • The `instantQuery` function implements the core logic for the "prom_instant_query" tool, executing the PromQL query against the Prometheus API.
    export async function instantQuery(args: Record<string, unknown>): Promise<string> {
      const query = args.query as string;
      if (!query) throw new Error("PromQL query is required");
    
      const url = `${config.prometheusUrl}/api/v1/query?query=${encodeURIComponent(query)}`;
      const res = await fetch(url);
      if (!res.ok) throw new Error(`Prometheus query failed: ${res.status} ${res.statusText}`);
    
      const data = (await res.json()) as { status: string; error?: string; data: { result: Array<{ metric: Record<string, string>; value: [number, string] }> } };
      if (data.status !== "success") throw new Error(`Query error: ${data.error || "unknown"}`);
    
      const results = data.data.result || [];
      if (results.length === 0) return `No results for query: ${query}`;
    
      const headers = ["METRIC", "VALUE"];
      const rows = results.map((r) => {
        const labels = Object.entries(r.metric)
          .map(([k, v]) => `${k}="${v}"`)
          .join(", ");
        return [labels || "{}", r.value[1]];
      });
    
      return `Query: ${query}\n\n${formatTable(headers, rows)}`;
    }
  • The tool definition (name, description, inputSchema) for "prom_instant_query" is registered here.
    {
      name: "prom_instant_query",
      description: "Execute a PromQL instant query and return current values",
      inputSchema: {
        type: "object" as const,
        properties: {
          query: { type: "string", description: "PromQL query expression" },
        },
        required: ["query"],
      },
    },
  • The `handlePrometheusTool` function routes the "prom_instant_query" request to the `instantQuery` function.
    switch (name) {
      case "prom_instant_query": return instantQuery(a);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool executes a query and returns current values, but lacks critical details such as authentication requirements, rate limits, error handling, or what 'current values' entail (e.g., format, timestamps). This is inadequate for a tool that likely interacts with a monitoring system.

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, efficient sentence that front-loads the core action. There's no wasted verbiage, though it could benefit from slightly more detail given the lack of annotations and output schema.

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 complexity of querying a monitoring system, no annotations, and no output schema, the description is insufficient. It doesn't explain return values, error conditions, or behavioral traits, leaving significant gaps for an AI agent to use the tool effectively.

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 description adds no parameter-specific information beyond what the input schema provides, which has 100% coverage. It mentions 'PromQL instant query' but doesn't elaborate on the 'query' parameter's syntax or examples. The baseline score of 3 reflects that the schema does the heavy lifting, but the description doesn't enhance understanding.

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 ('Execute a PromQL instant query') and the resource ('PromQL'), making the purpose understandable. However, it doesn't explicitly differentiate from its sibling 'prom_range_query', which is a notable gap since both are Prometheus query tools.

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?

The description provides no guidance on when to use this tool versus alternatives like 'prom_range_query' or other monitoring tools in the sibling list. There's no mention of prerequisites, context, or exclusions, leaving usage entirely implicit.

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/batu-sonmez/infraclaude'

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