list_logs
Retrieve and manage PocketBase API request logs with filtering, sorting, and pagination options for efficient log analysis.
Instructions
List API request logs from PocketBase with filtering, sorting, and pagination.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | PocketBase filter string (e.g., "method='GET'"). | |
| page | No | Page number (defaults to 1). | |
| perPage | No | Items per page (defaults to 30, max 500). | |
| sort | No | PocketBase sort string (e.g., "-created,url"). |
Implementation Reference
- src/tools/log-tools.ts:69-82 (handler)The core handler function that executes the list_logs tool logic: destructures arguments, calls PocketBase logs.getList with pagination and filter, and returns JSON stringified result.async function listLogs(args: ListLogsArgs, pb: PocketBase): Promise<ToolResult> { const { page = 1, perPage = 30, filter, sort } = args; // Make the API request to list logs const result = await pb.logs.getList( page, perPage, { filter }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/types/tool-types.ts:76-81 (schema)TypeScript interface defining the expected input shape (ListLogsArgs) for the list_logs tool, used for type safety in the handler.export interface ListLogsArgs { page?: number; perPage?: number; filter?: string; sort?: string; }
- src/tools/log-tools.ts:9-23 (registration)ToolInfo object defining the list_logs tool's metadata (name, description, inputSchema), part of logToolInfo array exported via listLogTools() for registration.const logToolInfo: ToolInfo[] = [ { name: 'list_logs', description: 'List API request logs from PocketBase with filtering, sorting, and pagination.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number (defaults to 1).', minimum: 1 }, perPage: { type: 'number', description: 'Items per page (defaults to 30, max 500).', minimum: 1, maximum: 500 }, filter: { type: 'string', description: 'PocketBase filter string (e.g., "method=\'GET\'").' }, sort: { type: 'string', description: 'PocketBase sort string (e.g., "-created,url").' } }, required: [], }, },
- src/tools/index.ts:15-25 (registration)Main registration function that includes list_logs by spreading listLogTools() into the full tools array provided to MCP.export function registerTools(): { tools: ToolInfo[] } { // Use ToolInfo[] const tools: ToolInfo[] = [ // Use ToolInfo[] ...listRecordTools(), ...listCollectionTools(), ...listFileTools(), ...listMigrationTools(), // Uncommented ...listLogTools(), // Add log tools ...listCronTools(), // Add cron tools ]; return { tools }; }
- src/tools/log-tools.ts:52-65 (helper)Helper dispatcher for log tools that routes 'list_logs' calls to the listLogs handler function.// Handle calls for log-related tools export async function handleLogToolCall(name: string, args: any, pb: PocketBase): Promise<ToolResult> { switch (name) { case 'list_logs': return listLogs(args as ListLogsArgs, pb); case 'get_log': return getLog(args as GetLogArgs, pb); case 'get_logs_stats': return getLogsStats(args as GetLogsStatsArgs, pb); default: // This case should ideally not be reached due to routing in index.ts throw new Error(`Unknown log tool: ${name}`); } }