Skip to main content
Glama

get-kv

Retrieve specific values from the Consul MCP Server's key-value (KV) store by specifying the desired key, enabling quick access to stored data.

Instructions

Get a value from the KV store

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoKey to get from the KV store

Implementation Reference

  • The handler function that executes the get-kv tool logic: retrieves the KV value using consul.kv.get(key), handles errors, formats with formatKVPair, and returns formatted text.
    async ({ key }) => {
      try {
        const data = await consul.kv.get(key);
        if (!data) {
          return { content: [{ type: "text", text: `No value found for key: ${key}` }] };
        }
        
        const kvText = formatKVPair(data);
        return { content: [{ type: "text", text: kvText }] };
      } catch (error) {
        console.error("Error getting KV:", error);
        return { content: [{ type: "text", text: `Error getting value for key: ${key}` }] };
      }
    }
  • Registration of the get-kv tool via server.tool within registerKVStore function, including description, input schema, and handler.
    server.tool(
      "get-kv",
      "Get a value from the KV store",
      {
        key: z.string().default("").describe("Key to get from the KV store"),
      },
      async ({ key }) => {
        try {
          const data = await consul.kv.get(key);
          if (!data) {
            return { content: [{ type: "text", text: `No value found for key: ${key}` }] };
          }
          
          const kvText = formatKVPair(data);
          return { content: [{ type: "text", text: kvText }] };
        } catch (error) {
          console.error("Error getting KV:", error);
          return { content: [{ type: "text", text: `Error getting value for key: ${key}` }] };
        }
      }
    );
  • Zod input schema for the get-kv tool defining the 'key' parameter.
    {
      key: z.string().default("").describe("Key to get from the KV store"),
  • Helper function formatKVPair used in the get-kv handler to format the retrieved KV pair, decoding base64-encoded value.
    export function formatKVPair(pair: KVPair): string {
      // Decode base64 value if it exists
      let value = "No value";
      if (pair.Value !== null && pair.Value !== undefined) {
        try {
          // Consul stores values as base64 encoded strings
          value = atob(pair.Value);
        } catch (e) {
          value = pair.Value;
        }
      }
      
      return [
        `Key: ${pair.Key || "Unknown"}`,
        `Value: ${value}`,
        `Flags: ${pair.Flags || 0}`,
        `Last Modified Index: ${pair.ModifyIndex || "Unknown"}`,
        "---",
      ].join("\n");
    }
  • src/server.ts:41-41 (registration)
    Invocation of registerKVStore which registers the get-kv tool (among others) on the MCP server.
    registerKVStore(server, consul);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic action but doesn't cover critical aspects like read-only nature (implied but not explicit), error handling for missing keys, performance characteristics, or authentication requirements. This leaves significant gaps for agent understanding.

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?

The description is extremely concise - a single sentence that directly states the tool's purpose without any unnecessary words. It's front-loaded and wastes no space, making it efficient for quick comprehension.

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?

For a simple read operation with no annotations and no output schema, the description is insufficient. It doesn't explain what happens when the key doesn't exist, what format the returned value has, or any constraints on key naming. Given the context of KV store operations, more behavioral context would be helpful.

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 doesn't add any parameter information beyond what's already in the schema (which has 100% coverage). The schema fully documents the single 'key' parameter, so the baseline score of 3 is appropriate as the description doesn't compensate but doesn't detract either.

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 ('Get') and resource ('value from the KV store'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list-kv' (which lists keys) or 'put-kv' (which stores values), missing explicit sibling distinction.

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 'list-kv' for browsing keys or 'put-kv' for storing values. It lacks any context about prerequisites, error conditions, or typical use cases.

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

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

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