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
114 lines • 3.66 kB
TypeScript
/**
* Resource Existence Validation Utilities for Firewalla MCP Server
* Provides pre-flight checks for resource operations to prevent timeout errors
*/
import type { FirewallaClient } from '../firewalla/client.js';
/**
* Resource types that can be validated
*/
export type ResourceType = 'rule' | 'alarm' | 'device' | 'target_list' | 'box' | 'flow';
/**
* Resource existence check result
*/
export interface ResourceExistenceResult {
exists: boolean;
resourceId: string;
resourceType: ResourceType;
error?: string;
metadata?: Record<string, unknown>;
}
/**
* Resource operation wrapper result
*/
export interface ResourceOperationResult<T> {
success: boolean;
result?: T;
error?: any;
existenceCheck?: ResourceExistenceResult;
}
/**
* Configuration for resource operations
*/
export interface ResourceOperationConfig {
/** Whether to skip existence check (for performance) */
skipExistenceCheck?: boolean;
/** Custom timeout for existence check */
checkTimeoutMs?: number;
/** Whether to cache existence results */
cacheResults?: boolean;
}
/**
* Resource validator class with existence checking capabilities
*/
export declare class ResourceValidator {
private static existenceCache;
private static readonly CACHE_TTL_MS;
/**
* Check if a rule exists
*/
static checkRuleExists(ruleId: string, firewalla: FirewallaClient): Promise<ResourceExistenceResult>;
/**
* Check if an alarm exists
*/
static checkAlarmExists(alarmId: string, firewalla: FirewallaClient): Promise<ResourceExistenceResult>;
/**
* Check if a device exists
*/
static checkDeviceExists(deviceId: string, firewalla: FirewallaClient): Promise<ResourceExistenceResult>;
/**
* Generic resource existence checker
*/
static checkResourceExists(resourceType: ResourceType, resourceId: string, firewalla: FirewallaClient): Promise<ResourceExistenceResult>;
/**
* Wrapper for resource operations that includes existence checking
*/
static withResourceCheck<T>(resourceType: ResourceType, resourceId: string, firewalla: FirewallaClient, operation: () => Promise<T>, config?: ResourceOperationConfig): Promise<ResourceOperationResult<T>>;
/**
* Create standardized "resource not found" error response
*/
static createResourceNotFoundResponse(toolName: string, resourceType: ResourceType, resourceId: string, existenceCheck?: ResourceExistenceResult): {
content: Array<{
type: string;
text: string;
}>;
isError: true;
};
/**
* Clear existence cache (useful for testing or when resources change frequently)
*/
static clearCache(): void;
/**
* Get cache statistics
*/
static getCacheStats(): {
size: number;
entries: Array<{
key: string;
age: number;
exists: boolean;
}>;
};
/**
* Clean up expired cache entries
*/
static cleanupCache(): number;
}
/**
* Convenience function for checking rule existence and creating error response
*/
export declare function validateRuleExists(ruleId: string, toolName: string, firewalla: FirewallaClient): Promise<{
exists: true;
} | {
exists: false;
errorResponse: any;
}>;
/**
* Convenience function for checking alarm existence and creating error response
*/
export declare function validateAlarmExists(alarmId: string, toolName: string, firewalla: FirewallaClient): Promise<{
exists: true;
} | {
exists: false;
errorResponse: any;
}>;
//# sourceMappingURL=resource-validator.d.ts.map