Skip to main content
Glama

List Sessions

listSessions
Read-onlyIdempotent

List active Claude CLI sessions tracked by the server, returning session metadata including IDs, models, timing, turn counts, and cumulative cost. Use to check available sessions before resuming with a sessionId. No cost, local lookup only.

Instructions

List active Claude CLI sessions tracked by this server. Returns session metadata (IDs, models, timing, turn counts, cumulative cost) for orchestration. Use to check available sessions before resuming with sessionId. No cost (local lookup only).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the listSessions tool. Calls sessionStore.list() and returns the JSON-formatted list of active sessions with metadata.
    server.registerTool(
      "listSessions",
      {
        title: "List Sessions",
        description: listSessionsDescription,
        inputSchema: {},
        annotations: listSessionsAnnotations,
      },
      async () => {
        const start = Date.now();
        const sessions = sessionStore.list();
        return {
          content: [{ type: "text" as const, text: JSON.stringify(sessions, null, 2) }],
          _meta: buildMeta({ durationMs: Date.now() - start }),
        };
      },
  • src/index.ts:296-312 (registration)
    Registration of the listSessions tool on the MCP server with title, description, inputSchema, and annotations.
    server.registerTool(
      "listSessions",
      {
        title: "List Sessions",
        description: listSessionsDescription,
        inputSchema: {},
        annotations: listSessionsAnnotations,
      },
      async () => {
        const start = Date.now();
        const sessions = sessionStore.list();
        return {
          content: [{ type: "text" as const, text: JSON.stringify(sessions, null, 2) }],
          _meta: buildMeta({ durationMs: Date.now() - start }),
        };
      },
    );
  • Input schema is empty (no input parameters needed) for listSessions.
    inputSchema: {},
    annotations: listSessionsAnnotations,
  • SessionStore.list() method that returns all active sessions sorted by lastUsedAt descending (most recent first), after evicting expired entries.
    list(): SessionEntry[] {
      this.evictExpired();
      return Array.from(this.store.values())
        .map((e) => ({ ...e }))
        .sort((a, b) => b.lastUsedAt - a.lastUsedAt);
    }
  • Annotations for listSessions: read-only, non-destructive, idempotent, closed-world (purely local, no side effects).
    export const listSessionsAnnotations: ToolAnnotations = {
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: true,
      openWorldHint: false,
    };
Behavior5/5

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

Annotations already indicate read-only, non-destructive, and idempotent behavior. The description adds further context: 'No cost (local lookup only)' and specifies the metadata returned, enhancing transparency.

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 two sentences long, efficient, and front-loaded with the main purpose. Every sentence adds value without redundancy.

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

Completeness5/5

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

Given no parameters and a simple purpose, the description is complete. It mentions return metadata and usage context, making it sufficient for the agent to invoke correctly.

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 tool has no parameters, so schema coverage is 100%. The description does not need to add parameter semantics, but provides sufficient context for usage without parameters.

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?

The description clearly states that the tool lists active sessions and returns specific metadata, using a specific verb (list) and resource (sessions). It is distinct from sibling tools like ping, query, search, and structured.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool: 'Use to check available sessions before resuming with sessionId.' It also notes that it has no cost, implying it can be called freely.

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/hampsterx/claude-mcp-bridge'

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