MCP server integrating RooCode Memory Bank pattern with Sequential Thinking
npm install thinking-memory-bankA custom MCP server that combines the 'RooCode Memory Bank' pattern with the 'Sequential Thinking' methodology to provide structured context persistence with dynamic reasoning capabilities.
The Thinking Memory Bank MCP server is a specialized implementation that integrates two powerful paradigms:
1. RooCode Memory Bank: A structured approach to maintaining project context across sessions using specialized Markdown files organized in a consistent structure.
2. Sequential Thinking: A step-by-step reasoning methodology that breaks down complex problems into manageable thoughts that can be revised, branched, and extended dynamically.
By combining these approaches, the server provides AI assistants with:
- Persistent context storage organized in a structured format
- Reasoning capabilities that can leverage and update this context
- Specialized tools for initializing, updating, and querying memory
- Integration of sequential thinking with memory operations
Once published to npm, install via npx (no installation required):
``bash`
npx thinking-memory-bank
`bashClone the repository
git clone https://github.com/herdeybayor/thinking-memory-bank.git
cd thinking-memory-bank
$3
If you want to publish your own version, see PUBLISHING.md for a complete guide.
Usage
$3
The MCP server can be started using the following command:
`bash
npm start
`This will launch the server on stdio, ready to receive MCP protocol messages.
$3
The server provides the following MCP tools:
#### Initialize Memory Bank
Creates the memory bank structure for a new project:
`json
{
"toolName": "initialize_memory_bank",
"params": {
"projectName": "My Project",
"projectDescription": "A description of my project",
"initialContext": "Additional context information"
}
}
`#### Update Memory
Updates a specific memory file with new information:
`json
{
"toolName": "update_memory",
"params": {
"memoryType": "activeContext",
"content": "New information to add",
"operation": "append",
"reason": "Adding current session goals"
}
}
`#### Query Memory
Retrieves relevant information from memory:
`json
{
"toolName": "query_memory",
"params": {
"query": "What are the project goals?",
"memoryTypes": ["productContext", "activeContext"]
}
}
`#### Sequential Thinking
Performs a step in a sequential thinking process with optional memory integration:
`json
{
"toolName": "sequential_thinking",
"params": {
"thought": "First, we need to understand the requirements...",
"thoughtNumber": 1,
"totalThoughts": 5,
"nextThoughtNeeded": true,
"contextQuery": "What are the current requirements?",
"updateMemory": true
}
}
`Architecture
The Thinking Memory Bank combines several components:
`
┌─────────────────────────┐
│ MCP Server Interface │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Tool Handlers │
└───────┬───────────┬─────┘
│ │
▼ ▼
┌───────────┐ ┌───────────┐
│ Memory │ │ Thinking │
│ Manager │ │ Engine │
└───────────┘ └───────────┘
`$3
The memory bank is organized with the following files:
- activeContext.md: Current session state and goals
- productContext.md: Overall project knowledge and context
- decisionLog.md: Record of decisions and their rationale
- progress.md: Documentation of completed work and future tasks
- systemPatterns.md: Recurring patterns and standards in the project
$3
Three operations are supported for memory updates:
- Append: Add new content to the end of a file
- Replace: Completely replace a file's content
- Merge: Intelligently update specific sections of a file
Development
$3
`
src/
├── index.ts # Main entry point
├── memory/ # Memory management
│ ├── memory-manager.ts # Memory file operations
│ └── memory-manager.test.ts
├── thinking/ # Sequential thinking
│ └── thinking-engine.ts
├── tools/ # MCP tool definitions
│ ├── tool-definitions.ts
│ ├── tool-handlers.ts
│ └── tool-handlers.test.ts
├── types/ # Type definitions
│ └── memory.ts
└── mcp/ # MCP server implementation
└── mock-mcp-sdk.ts # Mock SDK implementation
`$3
Run the test suite with:
`bash
npm test
`References
This project is based on the following:
- RooCode Memory Bank - The original Memory Bank implementation
- MCP Sequential Thinking Server - The reference implementation for Sequential Thinking
Using with Roo Code
The Thinking Memory Bank MCP server is designed to integrate smoothly with Roo Code. Here's how to set it up:
$3
Add the following to your VS Code
mcp.json configuration file:#### Option A: Using Published npm Package (Recommended)
`json
{
"servers": {
"thinking-memory-bank": {
"command": "npx",
"args": ["-y", "thinking-memory-bank"]
}
}
}
`#### Option B: Using Local Development Version
`json
{
"servers": {
"thinking-memory-bank": {
"command": "node",
"args": ["/absolute/path/to/thinking-memory-bank/dist/index.js"]
}
}
}
`You can open this file through:
- Command Palette (Ctrl+Shift+P) → "MCP: Open User Configuration"
- Or add it to
.vscode/mcp.json in your workspace$3
Once configured, you can use the Memory Bank tools within your Roo Code conversations:
#### Initializing a Memory Bank
When starting a new project:
`
I'd like to initialize a memory bank for this project. It's a React application for managing inventory.
`Roo will use the
initialize_memory_bank tool to create the memory structure.#### Updating Memory
To explicitly update memory with specific information:
`
Please update our project context with this information: The application needs to support both desktop and mobile views, with responsive design principles.
`#### Retrieving Context
To have Roo utilize previously stored knowledge:
`
What were our design decisions regarding the state management approach?
`Roo will use the
query_memory tool to retrieve this information.#### Sequential Thinking with Memory
For complex problems requiring step-by-step analysis:
`
Let's work through how to implement the authentication flow, considering the security requirements we established earlier.
`Roo will combine sequential thinking with memory queries to provide context-aware reasoning.
$3
You can explicitly manage the memory bank with commands like:
`
UMB (Update Memory Bank) - Used to manually trigger memory updates
Review memory - View the contents of specific memory files
``- Initialize the memory bank at the start of a project
- Periodically review memory contents to ensure accuracy
- Use explicit memory update requests for crucial information
- Let sequential thinking handle routine updates automatically
MIT