Skip to main content
Glama
mrwyndham

PocketBase MCP Server

delete_collection

Remove a collection from PocketBase database by specifying its ID or name. This administrative action permanently deletes the collection and its data.

Instructions

Delete a collection from PocketBase (admin only)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdOrNameYesID or name of the collection to delete

Implementation Reference

  • The primary handler function that executes the delete_collection tool. It authenticates as an admin using environment variables, deletes the specified collection via the PocketBase SDK, and returns a success message.
    private async deleteCollection(args: any) {
      try {
        // Authenticate with PocketBase as admin (required for collection deletion)
        await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? '');
        
        // Delete the collection
        await this.pb.collections.delete(args.collectionIdOrName);
        
        return {
          content: [
            {
              type: 'text',
              text: `Successfully deleted collection ${args.collectionIdOrName}`,
            },
          ],
        };
      } catch (error: unknown) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to delete collection: ${pocketbaseErrorMessage(error)}`
        );
      }
    }
  • Input schema definition for the delete_collection tool, specifying the required 'collectionIdOrName' parameter.
    inputSchema: {
      type: 'object',
      properties: {
        collectionIdOrName: {
          type: 'string',
          description: 'ID or name of the collection to delete',
        },
      },
      required: ['collectionIdOrName'],
    },
  • src/index.ts:651-664 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    {
      name: 'delete_collection',
      description: 'Delete a collection from PocketBase (admin only)',
      inputSchema: {
        type: 'object',
        properties: {
          collectionIdOrName: {
            type: 'string',
            description: 'ID or name of the collection to delete',
          },
        },
        required: ['collectionIdOrName'],
      },
    },
  • src/index.ts:693-694 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes to the deleteCollection method.
    case 'delete_collection':
      return await this.deleteCollection(request.params.arguments);

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

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