Skip to main content
Glama
fadlee

PocketBase MCP Server

by fadlee
errors.ts1.53 kB
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; /** * Create a standardized MCP error with proper error message formatting */ export function createMcpError( code: ErrorCode, message: string, error?: unknown ): McpError { const errorMessage = error ? `${message}: ${error instanceof Error ? error.message : JSON.stringify(error)}` : message; return new McpError(code, errorMessage); } /** * Handle and format errors from PocketBase operations */ export function handlePocketBaseError(operation: string, error: unknown): McpError { const errorMessage = error instanceof Error ? error.message : JSON.stringify(error); return new McpError( ErrorCode.InternalError, `Failed to ${operation}: ${errorMessage}` ); } /** * Validate required parameters and throw appropriate errors */ export function validateRequiredParams( params: Record<string, any>, requiredFields: string[] ): void { for (const field of requiredFields) { if (params[field] === undefined || params[field] === null) { throw new McpError( ErrorCode.InvalidParams, `Required parameter '${field}' is missing` ); } } } /** * Validate enum values */ export function validateEnumValue( value: any, allowedValues: string[], fieldName: string ): void { if (value && !allowedValues.includes(value)) { throw new McpError( ErrorCode.InvalidParams, `Invalid value for ${fieldName}. Allowed values: ${allowedValues.join(", ")}` ); } }

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