Skip to main content
Glama

list_documents

Retrieve paginated lists of documents from your PocketMCP database to browse indexed files and navigate large collections.

Instructions

List all documents with pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPagination options

Implementation Reference

  • Main handler function that executes the list_documents tool logic. Extracts pagination parameters from args, calls the database to retrieve documents, and returns formatted JSON response with document list and cursor information.
    async function handleListDocuments(args: any, db: DatabaseManager): Promise<any> {
        const { page } = args || {};
        const { limit = 50, cursor } = page || {};
    
      // Simple pagination for now - cursor not implemented
      const documents = db.listDocuments(limit, 0);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              documents: documents.map(doc => ({
                doc_id: doc.doc_id,
                external_id: doc.external_id,
                title: doc.title,
                source: doc.source,
                updated_at: doc.updated_at,
              })),
              next_cursor: documents.length === limit ? 'next' : undefined, // Simplified
            }, null, 2),
          },
        ],
      };
    }
  • src/server.ts:214-237 (registration)
    Tool registration where list_documents is registered with the MCP server. Includes the tool name, description, and input schema definition.
    {
      name: 'list_documents',
      description: 'List all documents with pagination',
      inputSchema: {
        type: 'object',
        properties: {
          page: {
            type: 'object',
            properties: {
              limit: {
                type: 'number',
                description: 'Number of documents per page (default: 50)',
                default: 50,
              },
              cursor: {
                type: 'string',
                description: 'Cursor for pagination (not implemented yet)',
              },
            },
            description: 'Pagination options',
          },
        },
      },
    },
  • Database helper method that queries SQLite for documents with pagination support (limit/offset). Returns Document array ordered by updated_at DESC.
    listDocuments(limit: number = 50, offset: number = 0): Document[] {
      const stmt = this.db.prepare(`
        SELECT * FROM documents 
        ORDER BY updated_at DESC 
        LIMIT ? OFFSET ?
      `);
      return stmt.all(limit, offset) as Document[];
    }
  • src/server.ts:253-254 (registration)
    Tool dispatch case in the switch statement that routes list_documents calls to the handler function.
    case 'list_documents':
      return await handleListDocuments(args, db);
Behavior2/5

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

Mentions pagination behavior, but without annotations, the description fails to disclose other critical traits: it doesn't confirm the read-only nature (though implied by 'list'), describe the return structure, or explain error conditions given the lack of output_schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise at only 5 words. While efficient in word count, this brevity contributes to underspecification given the lack of supporting annotations or output schema. No filler or redundancy.

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?

Severely incomplete given zero annotations and no output_schema. The description should compensate by describing what the tool returns (document structure, total count, etc.) and confirming read-only safety, but it provides only the minimal action verb.

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 descriptioncoverage is 100%, establishing a baseline of 3. The description mentions 'pagination' which loosely maps to the 'page' parameter object, but adds no syntax guidance, format details, or constraint explanations beyond what the schemaalready provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

States the basic action (list documents) and mentions pagination, but provides minimal scope definition. Does not explicitly distinguish from the 'search' sibling tool, which also retrieves documentsbut likely with filtering capabilities.

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?

Contains no guidance on when to use this tool versus alternatives like 'search' (for filtered queries) or 'upsert_documents'. Missing conditions or prerequisites for invocation.

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/Kailash-Sankar/PocketMCP'

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