Skip to main content
Glama
mrwyndham

PocketBase MCP Server

create_record

Add new records to PocketBase collections by specifying collection name and data fields for structured database entries.

Instructions

Create a new record in a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
dataYesRecord data

Implementation Reference

  • The main handler function that executes the create_record tool by calling PocketBase's create method on the specified collection with the provided data, returning the result as JSON text content.
    private async createRecord(args: any) {
      try {
        const result = await this.pb.collection(args.collection).create(args.data);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to create record: ${pocketbaseErrorMessage(error)}`
        );
      }
    }
  • Defines the input schema for the create_record tool, requiring 'collection' (string) and 'data' (object).
    inputSchema: {
      type: 'object',
      properties: {
        collection: {
          type: 'string',
          description: 'Collection name',
        },
        data: {
          type: 'object',
          description: 'Record data',
        },
      },
      required: ['collection', 'data'],
    },
  • src/index.ts:202-219 (registration)
    Registers the create_record tool in the ListTools response, including name, description, and input schema.
    {
      name: 'create_record',
      description: 'Create a new record in a collection',
      inputSchema: {
        type: 'object',
        properties: {
          collection: {
            type: 'string',
            description: 'Collection name',
          },
          data: {
            type: 'object',
            description: 'Record data',
          },
        },
        required: ['collection', 'data'],
      },
    },
  • src/index.ts:675-676 (registration)
    Registers the handler for create_record in the CallToolRequestSchema switch statement.
    case 'create_record':
      return await this.createRecord(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