UNPKG

@stackmemoryai/stackmemory

Version:

Project-scoped memory for AI coding tools. Durable context across sessions with MCP integration, frames, smart retrieval, Claude Code skills, and automatic hooks.

80 lines (66 loc) โ€ข 2.13 kB
/** * Test the trace detection integration with MCP server */ import LocalStackMemoryMCP from './server'; // Type for accessing private members in tests interface MCPTestInstance { traceDetector: { addToolCall: (call: { id: string; tool: string; timestamp: number; arguments: Record<string, unknown>; }) => void; flush: () => void; }; handleGetTraceStatistics: ( args: Record<string, unknown> ) => Promise<{ content: Array<{ text: string }> }>; handleGetTraces: (args: { limit: number; }) => Promise<{ content: Array<{ text: string }> }>; } async function testTraceIntegration() { console.log('๐Ÿงช Testing Trace Detection in MCP Server\n'); // Access the private methods through prototype const MCPClass = LocalStackMemoryMCP as unknown as new () => MCPTestInstance; const mcp = new MCPClass(); // Simulate tool calls directly on the trace detector console.log('๐Ÿ“‹ Simulating tool calls:'); // Simulate a search-driven trace const baseTime = Date.now(); mcp.traceDetector.addToolCall({ id: '1', tool: 'get_context', timestamp: baseTime, arguments: { query: 'authentication' }, }); console.log(' โœ“ Added get_context'); mcp.traceDetector.addToolCall({ id: '2', tool: 'add_decision', timestamp: baseTime + 1000, arguments: { content: 'Use JWT tokens', type: 'decision' }, }); console.log(' โœ“ Added add_decision'); mcp.traceDetector.addToolCall({ id: '3', tool: 'start_frame', timestamp: baseTime + 2000, arguments: { name: 'implement-auth' }, }); console.log(' โœ“ Added start_frame'); // Flush traces mcp.traceDetector.flush(); // Get statistics const stats = await mcp.handleGetTraceStatistics({}); console.log('\n๐Ÿ“Š Trace Statistics:'); console.log(stats.content[0].text); // Get traces const traces = await mcp.handleGetTraces({ limit: 10 }); console.log('\n๐Ÿ“ Detected Traces:'); console.log(traces.content[0].text); console.log('\nโœ… MCP Trace Integration Test Complete!'); } // Run the test testTraceIntegration().catch(console.error);