Skip to main content
Glama

meMCP - Memory-Enhanced Model Context Protocol

MIT License
23
2
test-streaming.jsβ€’6.59 kB
#!/usr/bin/env node import { SequentialGraphitiIntegration } from './src/core/SequentialGraphitiIntegration.js'; console.log('πŸš€ Testing meMCP Streaming Functionality\n'); async function testStreaming() { const integration = new SequentialGraphitiIntegration(); try { await integration.initialize(); console.log('βœ… meMCP system initialized\n'); // First, add some test facts for streaming console.log('πŸ“ Adding test facts for streaming...\n'); const testFacts = [ { content: 'React hooks must be called in order', type: 'constraint', domain: 'react' }, { content: 'Use async/await for better error handling', type: 'optimization', domain: 'javascript' }, { content: 'Always validate user input for security', type: 'security_concern', domain: 'security' }, { content: 'CSS Grid is better than Flexbox for 2D layouts', type: 'verified_pattern', domain: 'css' }, { content: 'Use semantic HTML elements for accessibility', type: 'verified_pattern', domain: 'html' }, { content: 'Debounce API calls to prevent rate limiting', type: 'optimization', domain: 'api' }, { content: 'Use TypeScript for large JavaScript projects', type: 'decision_rationale', domain: 'javascript' }, { content: 'Test your code before committing', type: 'workflow_improvement', domain: 'development' }, { content: 'Document your API endpoints thoroughly', type: 'workflow_improvement', domain: 'documentation' }, { content: 'Use environment variables for configuration', type: 'tool_configuration', domain: 'deployment' }, ]; for (const fact of testFacts) { await integration.memoryTools.storeInsight(fact); } console.log(`βœ… Added ${testFacts.length} test facts\n`); // Test streaming functionality console.log('πŸ”„ Testing streaming query...\n'); // Start a streaming query const streamId = await integration.memoryTools.streamingManager.createBatchStream( { query: '', type: '', domain: '' }, // Get all facts integration.factStore, { chunkSize: 3, maxResults: 20 } ); console.log(`πŸ“‘ Started stream with ID: ${streamId}`); // Get stream status const initialStatus = await integration.memoryTools.streamingManager.getStreamStatus(streamId); console.log(`πŸ“Š Initial status: ${initialStatus.progress.total} total facts, ${initialStatus.status} status`); // Process chunks let chunkCount = 0; let totalProcessed = 0; while (true) { try { const chunk = await integration.memoryTools.streamingManager.getNextChunk(streamId); chunkCount++; totalProcessed += chunk.facts.length; console.log(`\nπŸ“¦ Chunk ${chunkCount}:`); console.log(` Facts: ${chunk.facts.length}`); console.log(` Progress: ${chunk.progress.percentage}%`); console.log(` Remaining: ${chunk.progress.remainingFacts}`); if (chunk.progress.estimatedTimeRemaining) { console.log(` ETA: ${chunk.progress.estimatedTimeRemaining}s`); } // Show first fact in chunk as example if (chunk.facts.length > 0) { console.log(` Example: "${chunk.facts[0].summary}"`); } if (chunk.isLastChunk) { console.log(`\nβœ… Streaming completed!`); break; } // Add small delay to simulate real streaming await new Promise(resolve => setTimeout(resolve, 100)); } catch (error) { console.error(`❌ Error getting chunk: ${error.message}`); break; } } // Final status const finalStatus = await integration.memoryTools.streamingManager.getStreamStatus(streamId); console.log(`\nπŸ“ˆ Final Status:`); console.log(` Status: ${finalStatus.status}`); console.log(` Progress: ${finalStatus.progress.current}/${finalStatus.progress.total}`); console.log(` Duration: ${finalStatus.duration}ms`); console.log(` Chunks processed: ${chunkCount}`); console.log(` Total facts streamed: ${totalProcessed}`); // Test streaming manager stats const streamStats = integration.memoryTools.streamingManager.getStats(); console.log(`\nπŸ“Š Streaming Manager Stats:`); console.log(` Total streams: ${streamStats.totalStreams}`); console.log(` Active streams: ${streamStats.activeStreams}`); console.log(` Completed streams: ${streamStats.completedStreams}`); console.log(` Total facts processed: ${streamStats.totalFactsProcessed}`); // Test pause/resume functionality console.log(`\n⏸️ Testing pause/resume functionality...`); const streamId2 = await integration.memoryTools.streamingManager.createBatchStream( { query: 'javascript' }, integration.factStore, { chunkSize: 2, maxResults: 10 } ); // Get first chunk const firstChunk = await integration.memoryTools.streamingManager.getNextChunk(streamId2); console.log(`πŸ“¦ Got first chunk: ${firstChunk.facts.length} facts`); // Pause the stream const pauseResult = await integration.memoryTools.streamingManager.pauseStream(streamId2); console.log(`⏸️ Paused stream: ${pauseResult.status}`); // Try to get next chunk (should fail) try { await integration.memoryTools.streamingManager.getNextChunk(streamId2); console.log('❌ Should have failed to get chunk from paused stream'); } catch (error) { console.log(`βœ… Correctly blocked chunk from paused stream: ${error.message}`); } // Resume the stream const resumeResult = await integration.memoryTools.streamingManager.resumeStream(streamId2); console.log(`▢️ Resumed stream: ${resumeResult.status}`); // Now get next chunk (should work) const nextChunk = await integration.memoryTools.streamingManager.getNextChunk(streamId2); console.log(`πŸ“¦ Got chunk after resume: ${nextChunk.facts.length} facts`); // Cancel the stream const cancelResult = await integration.memoryTools.streamingManager.cancelStream(streamId2); console.log(`❌ Cancelled stream: processed ${cancelResult.processed}/${cancelResult.total} facts`); console.log('\nβœ… Streaming functionality test completed successfully!'); // Cleanup await integration.memoryTools.streamingManager.cleanupCompletedStreams(); console.log('🧹 Cleaned up completed streams'); } catch (error) { console.error('❌ Error in streaming test:', error); } finally { await integration.shutdown(); } } testStreaming().catch(console.error);

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/mixelpixx/meMCP'

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