Skip to main content
Glama
DynamicEndpoints

Document Extractor MCP Server

ensure_collection

Verifies document collection existence in PocketBase and creates it automatically when missing to maintain organized storage for extracted content.

Instructions

Check if the documents collection exists and create it if needed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'ensureCollectionExists' function checks for a document collection existence in PocketBase and creates it if it is missing.
    async function ensureCollectionExists() {
      await authenticateWhenNeeded();
      try {
        const collection = await pb.collections.getOne(DOCUMENTS_COLLECTION);
        debugLog('âś… Collection exists', { name: DOCUMENTS_COLLECTION, id: collection.id });
        return { exists: true, collection, created: false };
      } catch (error) {
        if (error.status === 404) {
          debugLog('📝 Creating collection', { name: DOCUMENTS_COLLECTION });
          const newCollection = await pb.collections.create(getDocumentsCollectionSchema());
          debugLog('âś… Collection created successfully', { name: DOCUMENTS_COLLECTION, id: newCollection.id });
          return { exists: true, collection: newCollection, created: true };
        } else {
          throw error;
        }
      }
    }
  • server.js:635-655 (registration)
    The 'ensure_collection' MCP tool is registered using server.tool, calling ensureCollectionExists internally.
    server.tool(
      'ensure_collection',
      'Check if the documents collection exists and create it if needed',
      {},
      async () => {
        try {
          await authenticateWhenNeeded();
          
          const result = await ensureCollectionExists();
          
          return {
            content: [{
              type: 'text',
              text: result.created 
                ? `âś… Documents collection "${DOCUMENTS_COLLECTION}" created successfully!\n\n` +
                  `**Collection Details:**\n` +
                  `- ID: ${result.collection.id}\n` +
                  `- Name: ${result.collection.name}\n` +
                  `- Type: ${result.collection.type}\n` +
                  `- Schema Fields: ${result.collection.schema?.length || 0}\n` +
                  `- Created: ${new Date(result.collection.created).toLocaleString()}`
Behavior3/5

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

With no annotations, the description carries full burden. It successfully discloses the conditional mutation pattern (creates only if missing), which is critical. However, lacks disclosure of return values, error conditions, idempotency guarantees, or permission requirements—significant gaps for a state-mutating tool without output schema coverage.

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?

Single sentence, 11 words, zero waste. Front-loaded with action verbs. Every word earns its place describing the dual check/create behavior.

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

Completeness3/5

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

Adequate for a 0-parameter tool but gaps remain: no description of return values (success indicator, created vs existed status) despite mutation semantics and missing output schema. Error conditions and permission requirements also absent.

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?

Zero parameters present, setting baseline to 4 per rubric. Description correctly implies no resource identifiers needed (operates on implicit 'documents' collection), avoiding parameter misdirection.

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?

Specific verbs (Check/Create) + specific resource (documents collection) clearly distinguish this from siblings like delete_document or collection_info. The conditional 'if needed' precisely captures the idempotent ensure pattern.

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?

Implies usage (when collection might not exist) but lacks explicit when-to-use guidance, prerequisites, or distinction from collection_info. No mention that this should be called before document operations if uncertainty exists.

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/DynamicEndpoints/documentation-mcp-using-pocketbase'

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