UNPKG

knowledgegraph-mcp

Version:

MCP server for enabling persistent knowledge storage for Claude through a knowledge graph with multiple storage backends

45 lines 2.21 kB
/** * Search configuration with environment variable support */ /** * Get search limits from environment variables with sensible defaults */ export function getSearchLimits() { return { maxResults: parseInt(process.env.KNOWLEDGEGRAPH_SEARCH_MAX_RESULTS || '100', 10), batchSize: parseInt(process.env.KNOWLEDGEGRAPH_SEARCH_BATCH_SIZE || '10', 10), maxClientSideEntities: parseInt(process.env.KNOWLEDGEGRAPH_SEARCH_MAX_CLIENT_ENTITIES || '10000', 10), clientSideChunkSize: parseInt(process.env.KNOWLEDGEGRAPH_SEARCH_CLIENT_CHUNK_SIZE || '1000', 10) }; } /** * Validate search limits to ensure they are within reasonable bounds */ export function validateSearchLimits(limits) { const validated = { maxResults: Math.max(1, Math.min(limits.maxResults, 1000)), batchSize: Math.max(1, Math.min(limits.batchSize, 50)), maxClientSideEntities: Math.max(100, Math.min(limits.maxClientSideEntities, 100000)), clientSideChunkSize: Math.max(100, Math.min(limits.clientSideChunkSize, 10000)) }; // Ensure maxClientSideEntities is at least as large as clientSideChunkSize if (validated.maxClientSideEntities < validated.clientSideChunkSize) { console.warn(`Search config warning: maxClientSideEntities (${validated.maxClientSideEntities}) is smaller than clientSideChunkSize (${validated.clientSideChunkSize}). Adjusting maxClientSideEntities to match.`); validated.maxClientSideEntities = validated.clientSideChunkSize; } // Log performance recommendations if (validated.maxClientSideEntities > 50000) { console.warn(`Search config warning: maxClientSideEntities (${validated.maxClientSideEntities}) is very high. Consider using database-level search for better performance.`); } if (validated.clientSideChunkSize > 5000) { console.warn(`Search config warning: clientSideChunkSize (${validated.clientSideChunkSize}) is very high. Consider smaller chunks for better memory usage.`); } return validated; } /** * Get validated search limits */ export function getValidatedSearchLimits() { return validateSearchLimits(getSearchLimits()); } //# sourceMappingURL=config.js.map