Skip to main content
Glama

Memory MCP Server

by cbuntingde
test-memory.js4.32 kB
#!/usr/bin/env node /** * @copyright 2025 Chris Bunting <cbuntingde@gmail.com> * @license MIT * * Simple test script to verify memory server functionality */ import { spawn } from 'child_process'; import { createInterface } from 'readline'; // Test the memory server const server = spawn('node', ['build/index.js'], { cwd: process.cwd(), stdio: ['pipe', 'pipe', 'inherit'] }); const rl = createInterface({ input: server.stdout, output: server.stdin, terminal: false }); // Send initialization request const initRequest = { jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'test-client', version: '1.0.0' } } }; server.stdin.write(JSON.stringify(initRequest) + '\n'); let responseCount = 0; rl.on('line', (line) => { try { const response = JSON.parse(line); console.log('Response:', JSON.stringify(response, null, 2)); responseCount++; if (responseCount === 1) { // After initialization, list tools const listToolsRequest = { jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} }; server.stdin.write(JSON.stringify(listToolsRequest) + '\n'); } else if (responseCount === 2) { // Test setting short-term memory const setMemoryRequest = { jsonrpc: '2.0', id: 3, method: 'tools/call', params: { name: 'set_short_term_memory', arguments: { sessionId: 'test-session-123', key: 'user_preference', value: 'poolside_seating', ttlMinutes: 60 } } }; server.stdin.write(JSON.stringify(setMemoryRequest) + '\n'); } else if (responseCount === 3) { // Test getting short-term memory const getMemoryRequest = { jsonrpc: '2.0', id: 4, method: 'tools/call', params: { name: 'get_short_term_memory', arguments: { sessionId: 'test-session-123', key: 'user_preference' } } }; server.stdin.write(JSON.stringify(getMemoryRequest) + '\n'); } else if (responseCount === 4) { // Test setting long-term memory const setLongTermRequest = { jsonrpc: '2.0', id: 5, method: 'tools/call', params: { name: 'set_long_term_memory', arguments: { userId: 'user-456', demographics: { age: 35, location: 'New York', occupation: 'Software Engineer' }, preferences: { seating: 'poolside', temperature: 'cool', communicationStyle: 'friendly' } } } }; server.stdin.write(JSON.stringify(setLongTermRequest) + '\n'); } else if (responseCount === 5) { // Test adding episodic memory const addEpisodicRequest = { jsonrpc: '2.0', id: 6, method: 'tools/call', params: { name: 'add_episodic_memory', arguments: { userId: 'user-456', sessionId: 'test-session-123', event: 'Guest requested poolside seating', context: 'Guest arrived for dinner and specifically asked for poolside seating', outcome: 'Guest was seated at poolside table and expressed satisfaction', sentiment: 'positive', tags: ['seating', 'poolside', 'dinner'] } } }; server.stdin.write(JSON.stringify(addEpisodicRequest) + '\n'); } else if (responseCount === 6) { console.log('\n✅ Memory server test completed successfully!'); server.kill(); process.exit(0); } } catch (error) { console.error('Error parsing response:', error); server.kill(); process.exit(1); } }); server.on('error', (error) => { console.error('Server error:', error); process.exit(1); }); server.on('exit', (code) => { if (code !== 0 && code !== null) { console.error('Server exited with code:', code); process.exit(code); } }); // Timeout after 10 seconds setTimeout(() => { console.error('Test timed out'); server.kill(); process.exit(1); }, 10000);

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/cbuntingde/memory-mcp-server'

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