Skip to main content
Glama
fadlee

PocketBase MCP Server

by fadlee

truncate_collection

Delete all records from a specified PocketBase collection to clear data while preserving the collection structure.

Instructions

Delete all records associated with the specified collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name or ID to truncate (delete all records)

Implementation Reference

  • The main handler function for the 'truncate_collection' tool. It calls PocketBase's truncate method to delete all records in the specified collection.
    export function createTruncateCollectionHandler(pb: PocketBase): ToolHandler { return async (args: TruncateCollectionArgs) => { try { await pb.collections.truncate(args.collection); return createJsonResponse({ success: true, message: `All records in collection '${args.collection}' have been deleted` }); } catch (error: unknown) { throw handlePocketBaseError("truncate collection", error); } }; }
  • src/server.ts:118-123 (registration)
    Registers the 'truncate_collection' tool in the MCP server, associating it with its schema and handler.
    name: "truncate_collection", description: "Delete all records associated with the specified collection", inputSchema: truncateCollectionSchema, handler: createTruncateCollectionHandler(pb), },
  • Defines the input schema for the 'truncate_collection' tool, requiring a 'collection' string parameter.
    export const truncateCollectionSchema = { type: "object", properties: { collection: { type: "string", description: "Collection name or ID to truncate (delete all records)", }, }, required: ["collection"], };

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/fadlee/pocketbase-mcp'

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