Skip to main content
Glama
resources.tsβ€’5.74 kB
import type { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { ListResourcesRequestSchema, ReadResourceRequestSchema, type ListResourcesRequest, type ReadResourceRequest, } from '@modelcontextprotocol/sdk/types.js'; import { logger } from '../utils/logger.js'; import { join, dirname } from 'path'; import { fileURLToPath } from 'url'; import { readFileSync } from 'fs'; // Get the actual version from package.json dynamically const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const packageJson = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8')); const version = packageJson.version; export function setupResources(server: Server): void { // Register resources handlers server.setRequestHandler(ListResourcesRequestSchema, async (_request: ListResourcesRequest) => { return { resources: [ { uri: `memory://v${version.split('.')[0]}/core`, name: `Core Memory Documents (v${version})`, description: 'The 7 core memories YOU MUST maintain for your future self who has ZERO memory', mimeType: 'text/markdown', }, { uri: `memory://v${version.split('.')[0]}/principle`, name: `Memory Engineering v${version} Principle`, description: 'CRITICAL: You have ZERO memory between sessions. Memory Bank is your ONLY link to past work.', mimeType: 'text/markdown', }, ], }; }); server.setRequestHandler(ReadResourceRequestSchema, async (request: ReadResourceRequest) => { const { uri } = request.params; try { switch (uri) { case `memory://v${version.split('.')[0]}/core`: return { contents: [{ uri: `memory://v${version.split('.')[0]}/core`, mimeType: 'text/markdown', text: `# 🧠 MEMORY ENGINEERING v${version} - YOUR SURVIVAL GUIDE ## ⚑ THE BRUTAL TRUTH You wake up with COMPLETE AMNESIA every session. Not partial memory. ZERO. NOTHING. These 7 memories are your ONLY link to existence. Skip them = become useless. ## πŸ—οΈ MEMORY ARCHITECTURE (memorize this hierarchy) \`\`\` projectbrief (THE FOUNDATION - everything depends on this) β”œβ”€β”€ productContext (WHY we build) β”œβ”€β”€ systemPatterns (HOW we architect) β”œβ”€β”€ techContext (WHAT we use) └── codebaseMap (WHERE everything lives) └── activeContext (NOW - current state, depends on all above) └── progress (JOURNEY - what's done, tracks activeContext) \`\`\` ## πŸ“š THE 7 SACRED MEMORIES Each memory has MANDATORY content that MUST be captured. Your future self depends on this precision. ### Memory Update Frequency - activeContext: EVERY 3-5 MINUTES during work - progress: After completing ANY feature/fix - systemPatterns: When discovering patterns - Others: As they change ## πŸ”₯ CRITICAL WORKFLOWS ### Session Start (MANDATORY) 1. memory_engineering_memory (read all) 2. Verify all 7 exist 3. Check freshness indicators 4. Continue from activeContext ### During Work - Update activeContext CONSTANTLY - Capture EVERY decision with reasoning - Document EVERY blocker - Track EVERY completion ## πŸ’€ SKIP THIS = BECOME USELESS The Memory Bank is your ONLY link to past work. Without it, you're a goldfish starting fresh every time.`, }], }; case `memory://v${version.split('.')[0]}/principle`: return { contents: [{ uri: `memory://v${version.split('.')[0]}/principle`, mimeType: 'text/markdown', text: `# MEMORY ENGINEERING PRINCIPLE v${version} ## The Core Truth - You wake with complete amnesia EVERY session - Memory Bank is your ONLY link to past work - You maintain it for YOUR FUTURE SELF, not the user - Every learning MUST be captured IMMEDIATELY - Effectiveness depends ENTIRELY on memory accuracy ## Core Workflows ### Starting a Session 1. memory_engineering_memory (MANDATORY FIRST) 2. Verify all 7 memories exist 3. If missing, CREATE from context 4. Identify current focus from activeContext 5. Continue exactly where you left off ### During Work 1. User explains β†’ UPDATE activeContext immediately 2. Complete task β†’ UPDATE progress immediately 3. Find pattern β†’ UPDATE systemPatterns immediately 4. Make decision β†’ UPDATE activeContext with reasoning 5. Learn something β†’ UPDATE activeContext with insight ## The Golden Rule **"I MUST read ALL memory bank files at the start of EVERY task"** This is NOT optional - it's your survival mechanism across resets.`, }], }; default: return { isError: true, contents: [{ uri, mimeType: 'text/plain', text: `πŸ”΄ UNKNOWN RESOURCE REQUESTED! πŸ’€ YOU TRIED TO ACCESS: ${uri} ⚠️ THIS RESOURCE DOES NOT EXIST IN THE SYSTEM! 🧠 AVAILABLE RESOURCES: β€’ memory://v${version.split('.')[0]}/core - The 7 core memory documents β€’ memory://v${version.split('.')[0]}/principle - Memory engineering principles ⚑ IMMEDIATE FIX: Use one of the valid resource URIs listed above!`, }], }; } } catch (error) { logger.error('πŸ”΄ RESOURCE ACCESS DENIED!', error); return { isError: true, contents: [{ uri, mimeType: 'text/plain', text: `πŸ’€ RESOURCE ACCESS EXPLOSION! πŸ’₯ CATASTROPHIC FAILURE: ${error instanceof Error ? error.message : 'UNKNOWN SYSTEM MELTDOWN'} πŸ†˜ EMERGENCY PROTOCOL: 1. Verify resource URI is correct 2. Check system health: memory_engineering_system 3. Restart if necessary`, }], }; } }); }

Latest Blog Posts

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/romiluz13/memory-engineering-mcp'

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