get_collection
Retrieve collection details from PocketBase databases to access schema information and configure data structures for application development.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/agent-cloudflare.ts:333-349 (handler)Direct implementation of get_collection tool handler: registers the tool with schema and executes pb.collections.getOne(nameOrId) to retrieve and return collection details as JSON.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-simple.ts:443-467 (handler)Direct implementation of get_collection tool handler in simple agent: registers with schema, ensures initialization, and fetches collection via pb.collections.getOne.'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-worker-compatible.ts:342-359 (handler)Core handler logic for get_collection tool in worker-compatible agent: retrieves collection details using pb.collections.getOne 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}`); }
- src/agent-worker-compatible.ts:122-127 (registration)Dispatch/registration point in request handler switch statement that validates args and calls getCollection for get_collection tool.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); }
- Input schema definition for get_collection tool in the list tools response.name: "get_collection", description: "Get detailed information about a specific collection", inputSchema: { type: "object", properties: { name: { type: "string", description: "Collection name" } }, required: ["name"] }