Skip to main content
Glama

list-sessions

Retrieve and display all active sessions in Consul for monitoring and management purposes using the Consul MCP Server interface.

Instructions

List all sessions in Consul

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'list-sessions' MCP tool, including its inline handler function that retrieves and formats Consul sessions.
    server.tool(
      "list-sessions",
      "List all sessions in Consul",
      {},
      async () => {
        try {
          const sessions = await consul.session.list();
          if (!sessions || sessions.length === 0) {
            return { content: [{ type: "text", text: "No sessions found" }] };
          }
    
          const sessionsText = `Sessions:\n\n${Object(sessions).map(formatSession).join("\n")}`;
          return { content: [{ type: "text", text: sessionsText }] };
        } catch (error) {
          console.error("Error listing sessions:", error);
          return { content: [{ type: "text", text: "Error listing sessions" }] };
        }
      }
    );
  • Helper function to format a Consul session into a readable string, used by the list-sessions handler.
    export function formatSession(session: Session): string {
      return [
        `ID: ${session.ID || "Unknown"}`,
        `Name: ${session.Name || "Unknown"}`,
        `Node: ${session.Node || "Unknown"}`,
        `Checks: ${session.Checks?.join(", ") || "None"}`,
        `LockDelay: ${session.LockDelay || "Unknown"}`,
        `Behavior: ${session.Behavior || "Unknown"}`,
        `TTL: ${session.TTL || "Unknown"}`,
        "---",
      ].join("\n");
    }
  • src/server.ts:42-42 (registration)
    Invocation of registerSessionTools which registers the list-sessions tool among session tools.
    registerSessionTools(server, consul);
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states it's a listing operation, implying read-only behavior, but lacks details on permissions, rate limits, pagination, output format, or error conditions. This is a significant gap for a tool with zero annotation coverage.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to scan and understand immediately.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what a 'session' is in Consul, what the output includes (e.g., session IDs, metadata), or behavioral aspects like sorting or filtering. For a tool with no structured data support, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate. A baseline of 4 is given since there are no parameters to document.

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 verb ('List') and resource ('all sessions in Consul'), making the purpose unambiguous. It distinguishes from siblings like 'destroy-session' (destructive) and 'get-agent-members' (different resource), though it doesn't explicitly differentiate from similar listing tools like 'list-kv' or 'list-catalog-services'.

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. It doesn't mention prerequisites (e.g., authentication), compare to similar listing tools (e.g., 'list-kv' for key-value pairs), or specify use cases (e.g., monitoring sessions vs. querying specific ones).

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