get_collection
Retrieve collection details from PocketBase databases using the Model Context Protocol. Simplify data management and access structured information for advanced database operations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/agent-simple.ts:442-467 (handler)Inline handler and registration for the 'get_collection' MCP tool. Validates input with Zod schema, ensures PocketBase initialization, fetches collection details using pb.collections.getOne(nameOrId), and returns formatted JSON response.this.server.tool( 'get_collection', { description: 'Get details of a specific collection', inputSchema: { nameOrId: z.string().describe('Collection name or ID') } }, async ({ nameOrId }) => { await this.ensureInitialized(); if (!this.pb) { throw new Error('PocketBase not initialized'); } try { const collection = await this.pb.collections.getOne(nameOrId); return { content: [{ type: 'text', text: JSON.stringify(collection, null, 2) }] }; } catch (error: any) { throw new Error(`Failed to get collection: ${error.message}`); } }
- src/agent-cloudflare.ts:333-349 (handler)Inline handler and registration for the 'get_collection' MCP tool in Cloudflare Agent. Fetches specific collection using PocketBase SDK and returns JSON details.this.server.tool( "get_collection", "Get details of a specific collection", { nameOrId: z.string().describe('Collection name or ID') }, async ({ nameOrId }) => { if (!this.pb) { throw new Error('PocketBase not initialized'); } const collection = await this.pb.collections.getOne(nameOrId); return { content: [{ type: 'text', text: JSON.stringify(collection, null, 2) }] }; }
- src/agent-worker-compatible.ts:342-359 (handler)Core handler function for 'get_collection' tool. Called from switch statement in tool request handler. Retrieves collection info via PocketBase and formats as MCP response.private async getCollection(name: string) { if (!this.pb) { throw new Error('PocketBase not configured'); } try { const collection = await this.pb.collections.getOne(name); return { content: [ { type: "text", text: JSON.stringify(collection, null, 2) } ] }; } catch (error: any) { throw new Error(`Failed to get collection: ${error.message}`); }
- Input schema definition for 'get_collection' tool provided in ListTools response. Specifies required 'name' parameter.name: "get_collection", description: "Get detailed information about a specific collection", inputSchema: { type: "object", properties: { name: { type: "string", description: "Collection name" } }, required: ["name"] }
- src/agent-worker-compatible.ts:122-127 (registration)Dispatch/registration logic in CallToolRequestHandler switch statement that validates arguments and delegates to getCollection handler.case "get_collection": { if (!args || typeof args !== "object" || typeof (args as any).name !== "string") { throw new Error("'name' is required and must be a string for get_collection"); } return await this.getCollection((args as any).name); }