UNPKG

mcp-server-tester-sse-http-stdio

Version:

MCP Server Tester with SSE support - Test MCP servers using HTTP, SSE, and STDIO transports

72 lines (71 loc) 2.44 kB
/** * Test discovery and registration system with MCP capability awareness */ export class TestRegistry { static tests = []; static registerTest(test) { this.tests.push(test); } static getAllTests() { return [...this.tests]; } /** * Get tests that should run based on server's advertised capabilities * Tests without requiredCapability always run (core protocol tests) */ static getApplicableTests(serverCapabilities) { return this.tests.filter(test => { // Always run tests that don't require specific capabilities (core protocol tests) if (!test.requiredCapability) { return true; } // Only run capability-specific tests if server supports them return serverCapabilities.has(test.requiredCapability); }); } /** * Get tests that are skipped because server doesn't support required capabilities */ static getSkippedTests(serverCapabilities) { return this.tests.filter(test => { return test.requiredCapability && !serverCapabilities.has(test.requiredCapability); }); } static getTestsByCategory(category) { return this.tests.filter(test => test.category === category); } static getTestsByCategories(categories) { return this.tests.filter(test => categories.includes(test.category)); } /** * Get tests by capability requirement */ static getTestsByCapability(capability) { return this.tests.filter(test => test.requiredCapability === capability); } /** * Get tests that don't require any specific capability (core protocol tests) */ static getCoreTests() { return this.tests.filter(test => !test.requiredCapability); } static getAvailableCategories() { const categories = new Set(this.tests.map(test => test.category)); return Array.from(categories).sort(); } /** * Get capabilities that have tests registered for them */ static getTestedCapabilities() { const capabilities = new Set(this.tests .map(test => test.requiredCapability) .filter((cap) => cap !== undefined)); return Array.from(capabilities).sort(); } static clear() { this.tests = []; } } export function registerComplianceTest(test) { TestRegistry.registerTest(test); }