UNPKG

firewalla-mcp-server

Version:

Model Context Protocol (MCP) server for Firewalla MSP API - Provides real-time network monitoring, security analysis, and firewall management through 28 specialized tools compatible with any MCP client

100 lines 3.28 kB
/** * Cursor Validation Utilities for Firewalla MCP Server * Provides comprehensive cursor format validation and standardized error handling */ import type { ValidationResult } from '../types.js'; /** * Cursor validation configuration */ export interface CursorValidationConfig { /** Maximum allowed cursor length */ maxLength?: number; /** Allowed cursor format patterns */ allowedPatterns?: RegExp[]; /** Whether to allow empty cursors */ allowEmpty?: boolean; /** Whether to perform strict format validation */ strictValidation?: boolean; /** Whether to check for suspicious patterns (security-focused validation) */ checkSuspiciousPatterns?: boolean; } /** * Cursor validation error details */ export interface CursorValidationError { type: 'format' | 'length' | 'pattern' | 'empty' | 'invalid_type'; message: string; providedValue: unknown; expectedFormat?: string; } /** * Enhanced cursor validation result */ export interface CursorValidationResult extends ValidationResult { validationError?: CursorValidationError; suggestions?: string[]; } /** * Cursor validation utilities */ export declare class CursorValidator { /** * Validate cursor format and return detailed validation result * * @param cursor - The cursor value to validate * @param paramName - Name of the parameter for error messages * @param config - Validation configuration * @returns Detailed validation result */ static validateCursor(cursor: unknown, paramName?: string, config?: Partial<CursorValidationConfig>): CursorValidationResult; /** * Create standardized error response for cursor validation failures */ static createCursorErrorResponse(toolName: string, validationResult: CursorValidationResult, paramName?: string): { content: Array<{ type: string; text: string; }>; isError: true; }; /** * Quick validation for simple use cases * * @param cursor - Cursor to validate * @param allowEmpty - Whether to allow empty/null cursors * @returns True if valid, false otherwise */ static isValidCursor(cursor: unknown, allowEmpty?: boolean): boolean; /** * Sanitize cursor value, returning undefined for invalid cursors * * @param cursor - Cursor to sanitize * @param config - Validation configuration * @returns Sanitized cursor or undefined */ static sanitizeCursor(cursor: unknown, config?: Partial<CursorValidationConfig>): string | undefined; /** * Generate example valid cursor for documentation */ static getExampleCursor(): string; /** * Get cursor format documentation */ static getCursorFormatInfo(): { description: string; formats: string[]; examples: string[]; restrictions: string[]; }; } /** * Convenience function for cursor validation in handlers */ export declare function validateCursorParameter(cursor: unknown, toolName: string, paramName?: string, config?: Partial<CursorValidationConfig>): { isValid: true; cursor: string | undefined; } | { isValid: false; errorResponse: any; }; //# sourceMappingURL=cursor-validator.d.ts.map