Skip to main content
Glama
fadlee

PocketBase MCP Server

by fadlee

upload_file

Upload a file to a specific record in PocketBase by providing the collection, record ID, file field name, file content, and file name.

Instructions

Upload a file to a record in PocketBase

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesThe name or ID of the collection
fileContentYesThe raw content of the file as a string
fileFieldYesThe name of the file field in the collection schema
fileNameYesThe desired name for the uploaded file (e.g., 'report.txt')
recordIdYesThe ID of the record to attach the file to

Implementation Reference

  • Factory function creating the ToolHandler for uploading file content as Blob via FormData to a PocketBase record update.
    export function createUploadFileHandler(pb: PocketBase): ToolHandler {
      return async (args: UploadFileArgs) => {
        try {
          const { collection, recordId, fileField, fileContent, fileName } = args;
          
          // Create a Blob from the file content string
          const blob = new Blob([fileContent]);
          
          // Create a FormData object and append the file
          const formData = new FormData();
          formData.append(fileField, blob, fileName);
          
          // Update the record with the file
          const record = await pb.collection(collection).update(recordId, formData);
          
          return createJsonResponse({
            success: true,
            message: `File '${fileName}' uploaded successfully to record ${recordId}`,
            record
          });
        } catch (error: unknown) {
          throw handlePocketBaseError("upload file", error);
        }
      };
    }
  • Input schema (Zod) defining required parameters for the upload_file tool: collection, recordId, fileField, fileContent (string), fileName.
    export const uploadFileSchema = {
      type: "object" as const,
      properties: {
        collection: {
          type: "string" as const,
          description: "The name or ID of the collection"
        },
        recordId: {
          type: "string" as const,
          description: "The ID of the record to attach the file to"
        },
        fileField: {
          type: "string" as const,
          description: "The name of the file field in the collection schema"
        },
        fileContent: {
          type: "string" as const,
          description: "The raw content of the file as a string"
        },
        fileName: {
          type: "string" as const,
          description: "The desired name for the uploaded file (e.g., 'report.txt')"
        }
      },
      required: ["collection" as const, "recordId" as const, "fileField" as const, "fileContent" as const, "fileName" as const]
    };
  • src/server.ts:220-225 (registration)
    Tool registration in the MCP server array, specifying name, description, inputSchema, and handler factory call.
      name: "upload_file",
      description: "Upload a file to a record in PocketBase",
      inputSchema: uploadFileSchema,
      handler: createUploadFileHandler(pb),
    },
    {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action. It fails to mention critical aspects like required permissions, file size limits, supported formats, error handling, or whether the operation is idempotent, leaving significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 5 required parameters and no annotations or output schema, the description is insufficient. It lacks details on behavioral traits, error conditions, and practical usage context, leaving the agent under-informed about how to invoke it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema fully documents all 5 parameters. The description adds no additional semantic context beyond what's in the schema, such as examples or constraints, but doesn't need to compensate for gaps, resulting in a baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Upload a file') and target resource ('to a record in PocketBase'), distinguishing it from sibling tools like 'upload_file_from_url' which handles URL-based uploads. It directly communicates the core functionality without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'upload_file_from_url' or 'download_file', nor does it mention prerequisites such as authentication or record existence. It lacks context for decision-making in a multi-tool environment.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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