Skip to main content
Glama

List Shelves

list_shelves
Read-only

Retrieve available shelves for authenticated users to manage and access stored files through paginated results.

Instructions

List shelves available to the authenticated user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
shelvesYes
paginationYes

Implementation Reference

  • Main tool registration and handler for list_shelves. This function registers the tool with the MCP server and implements the async handler that calls the HTTP client and formats the response.
    export function registerListShelvesTool(
      server: McpServer,
      context: ToolContext,
    ): void {
      server.registerTool(
        "list_shelves",
        {
          title: "List Shelves",
          description: "List shelves available to the authenticated user",
          inputSchema,
          outputSchema,
          annotations: { readOnlyHint: true },
        },
        async (input, extra) => {
          try {
            const apiKey = context.getApiKey(extra);
            const client = context.createHttpClient(apiKey);
            const result = await client.listShelves({
              page: input.page,
              limit: input.limit,
            });
    
            return successResult(
              `Loaded ${result.data.length} shelves (page ${result.pagination.page}/${result.pagination.totalPages})`,
              {
                shelves: result.data,
                pagination: result.pagination,
              },
            );
          } catch (error) {
            return errorResult(error);
          }
        },
      );
    }
  • Input and output Zod schemas for the list_shelves tool. Defines the structure for pagination parameters (page, limit) and the response format with shelves array and pagination metadata.
    const inputSchema = {
      page: z.number().int().min(1).optional(),
      limit: z.number().int().min(1).max(100).optional(),
    };
    
    const outputSchema = {
      shelves: z.array(
        z.object({
          publicId: z.string(),
          name: z.string(),
          status: z.string(),
          template: z.string().nullable(),
          pageCount: z.number().nullable(),
          reviewMode: z.boolean(),
          createdAt: z.string(),
          updatedAt: z.string(),
        }),
      ),
      pagination: z.object({
        page: z.number(),
        limit: z.number(),
        total: z.number(),
        totalPages: z.number(),
      }),
    };
  • Tool registration entry point. Imports registerListShelvesTool and calls it within registerShelvTools to add the tool to the MCP server.
    import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
    import type { ToolContext } from "./context";
    import { registerCreateShelfTool } from "./create-shelf";
    import { registerGetShelfTreeTool } from "./get-shelf-tree";
    import { registerHydrateShelfTool } from "./hydrate-shelf";
    import { registerListShelvesTool } from "./list-shelves";
    import { registerReadShelfFileTool } from "./read-shelf-file";
    import { registerSearchShelfTool } from "./search-shelf";
    
    export function registerShelvTools(
      server: McpServer,
      context: ToolContext,
    ): void {
      registerListShelvesTool(server, context);
      registerGetShelfTreeTool(server, context);
      registerReadShelfFileTool(server, context);
      registerSearchShelfTool(server, context);
    
      if (context.config.enableWriteTools) {
        registerCreateShelfTool(server, context);
        registerHydrateShelfTool(server, context);
      }
    }
  • HTTP client method that makes the actual API request to list shelves. Handles pagination parameters and constructs the request URL.
    async listShelves(params?: {
      page?: number;
      limit?: number;
    }): Promise<ListShelvesResponse> {
      const search = new URLSearchParams();
      if (params?.page) search.set("page", String(params.page));
      if (params?.limit) search.set("limit", String(params.limit));
    
      const path =
        search.size > 0 ? `/v1/shelves?${search.toString()}` : "/v1/shelves";
    
      return this.requestJson<ListShelvesResponse>("GET", path);
    }
  • Helper functions used by the list_shelves handler to format success and error responses in the MCP tool result format.
    export function successResult(
      text: string,
      structuredContent: Record<string, unknown>,
    ): CallToolResult {
      return {
        content: [{ type: "text", text }],
        structuredContent,
      };
    }
    
    export function errorResult(error: unknown): CallToolResult {
      const normalized = toMcpToolError(error, "Tool execution failed");
    
      return {
        isError: true,
        content: [{ type: "text", text: normalized.message }],
        structuredContent: {
          error: serializeToolError(normalized),
        },
      };
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, so the agent knows this is a safe read operation. The description adds that it lists shelves 'available to the authenticated user,' which provides useful context about access control. However, it doesn't describe pagination behavior, rate limits, or other traits beyond what annotations cover, resulting in a baseline score.

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 that front-loads the core purpose ('List shelves') and adds necessary context ('available to the authenticated user'). There is zero wasted text, making it highly concise and well-structured for quick understanding.

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

Completeness4/5

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

Given the tool's low complexity (list operation), annotations covering safety (readOnlyHint), and an output schema (which handles return values), the description is reasonably complete. It specifies the resource and user scope, though it could improve by hinting at pagination or sibling tool distinctions. Overall, it provides adequate context for the agent.

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?

Schema description coverage is 0%, so the schema documents parameters (page, limit) without descriptions. The tool description doesn't mention parameters at all, failing to compensate for the coverage gap. With 2 parameters and no output schema details in the description, it meets the minimum viable baseline but adds no value beyond the schema.

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 ('List') and resource ('shelves'), with the scope 'available to the authenticated user' providing useful context. It distinguishes from siblings like 'get_shelf_tree' (hierarchical view) and 'search_shelf' (filtered search) by implying a straightforward listing without filtering or structuring. However, it doesn't explicitly name these distinctions, keeping it at a 4.

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

Usage Guidelines3/5

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

The description implies usage for retrieving available shelves, but lacks explicit guidance on when to use this tool versus alternatives like 'search_shelf' (for filtering) or 'get_shelf_tree' (for hierarchical data). No when-not-to-use or prerequisite information is provided, making it only adequate with implied context.

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/shelv-dev/shelv-mcp'

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