Skip to main content
Glama
portel-dev

NCP - Natural Context Provider

by portel-dev
final-coverage-push.test.ts4.98 kB
/** * Final Coverage Push - Simple targeted tests to reach 80% coverage * Focus on easy wins and edge cases */ import { describe, it, expect } from '@jest/globals'; import { DiscoveryEngine } from '../src/discovery/engine.js'; import { PersistentRAGEngine } from '../src/discovery/rag-engine.js'; describe('Final Coverage Push - Simple Tests', () => { describe('Discovery Engine Pattern Extraction', () => { it('should extract patterns from complex tool descriptions', async () => { const engine = new DiscoveryEngine(); // Test with tool that has complex description patterns await engine.indexTool({ id: 'complex:multi-operation-tool', name: 'multi-operation-tool', description: 'Create, read, update and delete multiple files in directory while executing commands and validating operations' }); // Should extract multiple verb-object patterns const stats = engine.getStats(); expect(stats.totalPatterns).toBeGreaterThan(5); }); it('should handle pattern extraction edge cases', async () => { const engine = new DiscoveryEngine(); // Test with empty and problematic descriptions const problematicTools = [ { id: 'empty:desc', name: 'empty-desc', description: '' }, { id: 'special:chars', name: 'special-chars', description: 'Tool with "quoted text" and (parentheses) and symbols @#$%' }, { id: 'long:name-with-many-parts', name: 'very-long-tool-name-with-many-hyphenated-parts', description: 'Normal description' } ]; for (const tool of problematicTools) { await engine.indexTool(tool); } // Should handle all cases without errors const stats = engine.getStats(); expect(stats.totalTools).toBe(3); }); it('should test findRelatedTools similarity calculation', async () => { const engine = new DiscoveryEngine(); // Index multiple related tools const tools = [ { id: 'fileops:read', name: 'fileops:read', description: 'Read file content from filesystem' }, { id: 'fileops:write', name: 'fileops:write', description: 'Write file content to filesystem' }, { id: 'mathops:calculate', name: 'mathops:calculate', description: 'Perform mathematical calculations' } ]; for (const tool of tools) { await engine.indexTool(tool); } // Find related tools for the read operation const related = await engine.findRelatedTools('fileops:read'); expect(related.length).toBeGreaterThan(0); // Should find write operation as related (similar description) const writeRelated = related.find(r => r.id === 'fileops:write'); expect(writeRelated).toBeTruthy(); expect(writeRelated?.similarity).toBeGreaterThan(0.3); }); }); describe('RAG Engine Basic Operations', () => { it('should handle minimal tool indexing', async () => { const ragEngine = new PersistentRAGEngine(); await ragEngine.initialize(); // Index tool with minimal description await ragEngine.indexMCP('minimal-server', [ { id: 'minimal:tool', name: 'tool', description: 'x', // Very short description inputSchema: {} } ]); // Test discovery with empty/minimal query const results = await ragEngine.discover('', 5); expect(Array.isArray(results)).toBe(true); }); it('should handle cache operations', async () => { const ragEngine = new PersistentRAGEngine(); await ragEngine.initialize(); // Index some tools await ragEngine.indexMCP('test-server', [ { id: 'test:refresh-tool', name: 'refresh-tool', description: 'Tool for testing cache refresh operations', inputSchema: {} } ]); // Test cache refresh await ragEngine.refreshCache(); // Test cache clear await ragEngine.clearCache(); // Should still work after clear const results = await ragEngine.discover('refresh', 1); expect(Array.isArray(results)).toBe(true); }); it('should handle domain classification', async () => { const ragEngine = new PersistentRAGEngine(); await ragEngine.initialize(); // Test with query that contains multiple domain indicators await ragEngine.indexMCP('multi-domain', [ { id: 'multi:payment-file-web', name: 'payment-file-web', description: 'Process payment files on web server database', inputSchema: {} } ]); const results = await ragEngine.discover('payment web database file', 3); expect(results.length).toBeGreaterThanOrEqual(0); }); }); });

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/portel-dev/ncp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server