Skip to main content
Glama

Get Shelf Tree

get_shelf_tree
Read-only

Retrieve the complete file structure and contents of a shelf to access and organize stored files efficiently.

Instructions

Get the full file tree and file contents for a shelf

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shelf_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
filesYes
shelf_idYes
file_countYes

Implementation Reference

  • Main implementation of get_shelf_tree tool. The registerGetShelfTreeTool function contains the handler logic that calls the shelv client's getTree method and formats the response with shelf_id, name, file_count, and files.
    export function registerGetShelfTreeTool(
      server: McpServer,
      context: ToolContext,
    ): void {
      server.registerTool(
        "get_shelf_tree",
        {
          title: "Get Shelf Tree",
          description: "Get the full file tree and file contents for a shelf",
          inputSchema,
          outputSchema,
          annotations: { readOnlyHint: true },
        },
        async (input, extra) => {
          try {
            const apiKey = context.getApiKey(extra);
            const client = context.createShelvClient(apiKey);
            const tree = await client.getTree(input.shelf_id);
    
            return successResult(
              `Loaded ${tree.fileCount} files for shelf ${tree.shelfPublicId}`,
              {
                shelf_id: tree.shelfPublicId,
                name: tree.name,
                file_count: tree.fileCount,
                files: tree.files,
              },
            );
          } catch (error) {
            return errorResult(error);
          }
        },
      );
    }
  • Input and output schema definitions for the get_shelf_tree tool. Input requires shelf_id (string), output returns shelf_id, name, file_count, and a record of files.
    const inputSchema = {
      shelf_id: z.string().min(1),
    };
    
    const outputSchema = {
      shelf_id: z.string(),
      name: z.string(),
      file_count: z.number(),
      files: z.record(z.string()),
    };
  • src/tools/index.ts:4-4 (registration)
    Import statement for registerGetShelfTreeTool function from get-shelf-tree module.
    import { registerGetShelfTreeTool } from "./get-shelf-tree";
  • registerShelvTools function that registers all tools including get_shelf_tree. The get_shelf_tree tool is always registered on line 15.
    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);
      }
    }
  • Helper functions successResult and errorResult used by the get_shelf_tree handler to format tool execution responses.
    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 declare readOnlyHint=true, indicating a safe read operation. The description adds value by specifying it retrieves 'full file tree and file contents', which clarifies scope beyond just metadata. However, it doesn't disclose behavioral traits like rate limits, authentication needs, or response format details, relying on annotations for basic safety.

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 action ('Get the full file tree and file contents'). There is no wasted wording, 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 moderate complexity (retrieving tree and contents), annotations cover read-only safety, and an output schema exists (so return values are documented elsewhere), the description is reasonably complete. It specifies scope but could improve by mentioning sibling differentiation or behavioral details like pagination.

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?

Schema description coverage is 0%, so the schema only documents 'shelf_id' as a required string. The description compensates by implying 'shelf_id' identifies the shelf to retrieve, adding semantic context. With only one parameter, this is sufficient for clarity, though it doesn't detail format constraints 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 verb ('Get') and resource ('full file tree and file contents for a shelf'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'read_shelf_file' (which might get individual files) or 'search_shelf' (which might search within shelves), leaving some ambiguity about uniqueness.

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 'read_shelf_file' or 'search_shelf'. It lacks context on prerequisites (e.g., needing a valid shelf_id) or exclusions, leaving the agent to infer usage based on tool names alone.

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