@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
text/typescript
/**
* 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);