Skip to main content
Glama

list_documents

Read-onlyIdempotent

Retrieve a paginated list of your saved documents, with optional filtering by folder name or ID.

Instructions

List your saved documents with pagination. Optionally filter by folder name or ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoOptional. Filter by folder name (case-insensitive) or folder ID.
limitNoMax results per page (default: 20, max: 100)
cursorNoPagination cursor from a previous response

Implementation Reference

  • The async handler function that executes the list_documents tool logic. It builds query parameters (folder, limit, cursor), sends a GET request to /v1/documents via the API client, and returns the JSON result.
      async ({ folder, limit, cursor }) => {
        try {
          const query: Record<string, string> = {};
          if (folder) query.folder = folder;
          if (limit) query.limit = String(limit);
          if (cursor) query.cursor = cursor;
          const result = await client.request(
            "GET",
            "/v1/documents",
            undefined,
            query,
          );
          return jsonResult(result);
        } catch (err) {
          return errorResult(err);
        }
      },
    );
  • Zod schema defining the input parameters for list_documents: optional folder (string), limit (number, 1-100, int), and cursor (string for pagination).
    {
      folder: z
        .string()
        .optional()
        .describe("Optional. Filter by folder name (case-insensitive) or folder ID."),
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .optional()
        .describe("Max results per page (default: 20, max: 100)"),
      cursor: z
        .string()
        .optional()
        .describe("Pagination cursor from a previous response"),
    },
  • src/tools.ts:129-173 (registration)
    Registration of the list_documents tool via server.tool(), which is called from the registerTools function in src/tools.ts, which in turn is called from createServerInstance in src/index.ts.
    server.tool(
      "list_documents",
      "List your saved documents with pagination. Optionally filter by folder name or ID.",
      {
        folder: z
          .string()
          .optional()
          .describe("Optional. Filter by folder name (case-insensitive) or folder ID."),
        limit: z
          .number()
          .int()
          .min(1)
          .max(100)
          .optional()
          .describe("Max results per page (default: 20, max: 100)"),
        cursor: z
          .string()
          .optional()
          .describe("Pagination cursor from a previous response"),
      },
      {
        title: "List Documents",
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
      async ({ folder, limit, cursor }) => {
        try {
          const query: Record<string, string> = {};
          if (folder) query.folder = folder;
          if (limit) query.limit = String(limit);
          if (cursor) query.cursor = cursor;
          const result = await client.request(
            "GET",
            "/v1/documents",
            undefined,
            query,
          );
          return jsonResult(result);
        } catch (err) {
          return errorResult(err);
        }
      },
    );
  • The jsonResult helper function used by the list_documents handler to format the API response as JSON text content.
    function jsonResult(data: unknown) {
      return {
        content: [
          { type: "text" as const, text: JSON.stringify(data, null, 2) },
        ],
      };
  • The errorResult helper function used by the list_documents handler to format API errors into error content.
    function errorResult(err: unknown) {
      if (err instanceof ApiError) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error ${err.status} (${err.code}): ${err.message}`,
            },
          ],
          isError: true,
        };
      }
      const message = err instanceof Error ? err.message : String(err);
      return {
        content: [{ type: "text" as const, text: `Error: ${message}` }],
        isError: true,
      };
    }
Behavior4/5

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

Annotations already mark it as read-only, idempotent, and non-destructive. The description adds pagination and filtering behavior, which goes beyond annotations, but omits details like rate limits or error handling.

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?

A single, front-loaded sentence that efficiently conveys the tool's main purpose and optional features with no wasted words.

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?

For a list operation with 3 optional parameters and no output schema, the description covers pagination and filtering adequately, leaving no critical gaps.

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?

Input schema provides 100% coverage of parameter descriptions, so the description adds little beyond stating optional filtering. Baseline 3 is appropriate.

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 the tool lists saved documents with pagination and optional filtering. It distinguishes from siblings like 'get_document' (single document) and 'create_document'.

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 listing with optional filtering, but no explicit guidance on when not to use or alternatives (e.g., search). Usage is clear from context but not fully explicit.

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/UnMarkdown/mcp-server'

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