Skip to main content
Glama
MCP Brain Context Manager

MCP Brain Context Manager

by Big0290

🧠 MCP Context Manager with Brain-Enhanced Memory

Python 3.10+ MCP Protocol License: MIT

A sophisticated Model Context Protocol (MCP) server that provides human brain-like memory management for AI agents. Features multilayered memory architecture, neural-style interconnections, and intelligent knowledge growth.

🎯 What This Solves

  • Context Loss: AI agents forgetting previous conversations and learned patterns

  • Knowledge Fragmentation: Scattered information across different sessions

  • Pattern Recognition: Missing connections between similar problems and solutions

  • Learning Efficiency: Inability to build upon past experiences and insights

  • Knowledge Management: No systematic way to organize and retrieve relevant context

Related MCP server: Memory Nexus MCP

⭐ Key Features

🧠 Brain-Like Memory System

  • Multilayered Architecture: Short-term, long-term, episodic, procedural, and semantic memory

  • Neural Connections: Automatic relationship discovery between memories

  • Memory Promotion: Frequently used knowledge becomes more accessible

  • Analogical Reasoning: Find similar solutions from different contexts

πŸ”— Intelligent Connections

  • 6 Connection Types: Semantic, temporal, causal, contextual, functional, analogical

  • Auto-Discovery: Finds relationships between memories automatically

  • Knowledge Graphs: Visualize how concepts interconnect

  • Learning Paths: Trace knowledge flow between concepts

πŸ“Š Advanced Features

  • MCP Protocol Compliant: Full compatibility with Cursor and other MCP clients

  • Performance Monitoring: Built-in analytics and optimization

  • Project Isolation: Separate memory contexts by project

  • Semantic Search: Vector-based similarity matching

  • Context Injection: Automatic relevant memory retrieval

πŸš€ Quick Start

1. Installation

git clone https://github.com/yourusername/mcp-context-manager-python.git
cd mcp-context-manager-python

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
# Run the automated setup script
python scripts/setup_cursor_brain_mcp.py

This will:

  • βœ… Test all components

  • βœ… Create MCP configuration

  • βœ… Install Cursor integration

  • βœ… Set up startup scripts

3. Manual Setup

Start the Brain-Enhanced Server

# With brain features (recommended)
python src/brain_enhanced_mcp_server.py

# Or simple server (basic features only)
python src/simple_mcp_server.py

Test the Server

python test_brain_mcp.py

Configure Your MCP Client

Add this to your MCP client configuration:

{
  "mcpServers": {
    "mcp-brain-context-manager": {
      "command": "python",
      "args": ["src/brain_enhanced_mcp_server.py"],
      "cwd": "/path/to/mcp-context-manager-python",
      "env": {
        "MCP_PROJECT_ID": "your-project",
        "MCP_LOG_LEVEL": "INFO"
      }
    }
  }
}

πŸ› οΈ Usage Examples

Basic Memory Operations

# Store memories (automatically enhanced with brain features)
await mcp_server.push_memory({
    "content": "React useEffect handles side effects in functional components",
    "memory_type": "fact",
    "tags": ["react", "hooks", "javascript"],
    "project_id": "my-web-app"
})

# Retrieve memories with semantic search
result = await mcp_server.fetch_memory({
    "query": "React performance optimization",
    "project_id": "my-web-app"
})

Brain-Enhanced Operations

# Find analogous past experiences
result = await mcp_server.search_similar_experiences({
    "query": "API rate limiting errors",
    "focus_areas": ["Error Handling", "APIs", "Performance"],
    "include_analogies": True
})

πŸ•ΈοΈ Knowledge Graph

# Build knowledge maps
graph = await mcp_server.get_knowledge_graph({
    "center_topic": "Database Optimization",
    "max_depth": 3
})

πŸ›€οΈ Knowledge Path Tracing

# Discover learning paths
path = await mcp_server.trace_knowledge_path({
    "from_concept": "Basic SQL",
    "to_concept": "Advanced Query Optimization"
})

πŸ“Š Memory Insights

# Analyze knowledge patterns
insights = await mcp_server.get_memory_insights({
    "project_id": "my-project",
    "include_recommendations": True
})

πŸ—οΈ Architecture

mcp-context-manager-python/
β”œβ”€β”€ 🎯 Core Components
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ brain_enhanced_mcp_server.py    # Main brain-enhanced server
β”‚   β”‚   β”œβ”€β”€ brain_memory_system.py          # Multilayered memory system
β”‚   β”‚   β”œβ”€β”€ brain_integration.py            # Integration layer
β”‚   β”‚   β”œβ”€β”€ simple_mcp_server.py            # Basic MCP server
β”‚   β”‚   └── performance_monitor.py          # Performance tracking
β”‚   └── mcp_memory_server/                  # Full-featured server components
β”‚       β”œβ”€β”€ core/                           # Core services
β”‚       β”œβ”€β”€ models/                         # Data models
β”‚       └── api/                            # API endpoints
β”‚
β”œβ”€β”€ πŸ§ͺ Testing & Examples
β”‚   β”œβ”€β”€ tests/                              # Comprehensive test suite
β”‚   β”œβ”€β”€ examples/                           # Usage examples
β”‚   └── test_brain_mcp.py                   # Quick server test
β”‚
β”œβ”€β”€ πŸ”§ Configuration & Scripts
β”‚   β”œβ”€β”€ scripts/                            # Setup and utility scripts
β”‚   β”œβ”€β”€ config.py                           # Main configuration
β”‚   └── cursor_mcp_config.json              # MCP client configuration
β”‚
β”œβ”€β”€ πŸ“š Documentation
β”‚   └── guides/                             # Detailed guides and documentation
β”‚       β”œβ”€β”€ BRAIN_MEMORY_SYSTEM_GUIDE.md    # Comprehensive user guide
β”‚       β”œβ”€β”€ BRAIN_ARCHITECTURE_SUMMARY.md   # Technical architecture
β”‚       └── QUICK_CURSOR_SETUP.md           # Quick setup guide
β”‚
└── πŸ’Ύ Data & Logs
    β”œβ”€β”€ data/                               # Database files
    └── logs/                               # Application logs

🧠 Brain Memory System

Memory Layers

  • Short-term: Working memory for temporary information (≀50 items)

  • Long-term: Persistent knowledge and facts

  • Episodic: Specific events and experiences ("I learned X while doing Y")

  • Procedural: Skills and learned patterns ("How to debug React performance")

  • Semantic: Conceptual knowledge and relationships

Connection Types

  • Semantic: Related concepts (useState ↔ useReducer)

  • Temporal: Time-based sequences (Step 1 β†’ Step 2)

  • Causal: Cause-effect relationships (Performance issue β†’ Solution)

  • Contextual: Same project/context

  • Functional: Similar tools/techniques

  • Analogical: Similar patterns across domains

Example Memory Insights

πŸ“Š Memory System Analysis

Memory Layer Distribution:
β€’ Long-term: 45 memories
β€’ Procedural: 23 memories
β€’ Episodic: 15 memories
β€’ Short-term: 8 memories

Connection Patterns:
β€’ Semantic: 45 connections (related concepts)
β€’ Contextual: 32 connections (same projects)
β€’ Functional: 15 connections (similar techniques)

πŸ’‘ Recommendations:
β€’ Strong React knowledge - consider creating procedural guides
β€’ Review dormant Python memories for valuable insights
β€’ Consider consolidating short-term memories

🎨 Available Tools

Core MCP Tools

Tool

Description

Key Parameters

push_memory

Store memory with brain enhancement

content, memory_type, tags, project_id

fetch_memory

Retrieve with brain-enhanced search

query, tags, memory_type, limit

get_context_summary

Generate context with brain insights

project_id, max_memories, focus_areas

Brain-Enhanced Tools

Tool

Description

Key Parameters

search_similar_experiences

Find analogous past experiences

query, focus_areas, include_analogies

get_knowledge_graph

Build interconnected knowledge maps

center_topic, max_depth, connection_types

get_memory_insights

Analyze knowledge patterns

project_id, include_recommendations

trace_knowledge_path

Discover learning paths

from_concept, to_concept, max_hops

promote_memory_knowledge

Boost important memories

memory_ids, target_layer, emotional_weight

⚑ Performance & Scalability

  • Semantic Search: Vector embeddings with similarity thresholds

  • Connection Pruning: Automatic cleanup of weak relationships

  • Memory Limits: Configurable limits per memory layer

  • Batch Operations: Efficient bulk processing

  • Performance Monitoring: Built-in analytics and recommendations

πŸ”§ Configuration

Environment Variables

# Core settings
MCP_PROJECT_ID=your-project-name
MCP_LOG_LEVEL=INFO
MCP_PERFORMANCE_MONITORING=true

# Brain system settings
BRAIN_SHORT_TERM_LIMIT=50
BRAIN_SIMILARITY_THRESHOLD=0.7
BRAIN_CONNECTION_STRENGTH_THRESHOLD=0.3

Advanced Configuration

# Customize brain system parameters
brain_system.config.update({
    "short_term_limit": 30,
    "similarity_threshold": 0.8,
    "memory_promotion_threshold": 5,
    "consolidation_threshold": 10
})

# Add custom hierarchies
brain_system.topic_hierarchy["YourDomain"] = [
    "Subdomain1", "Subdomain2", "Subdomain3"
]

πŸ§ͺ Testing

Run All Tests

python -m pytest tests/

Quick Server Test

python test_brain_mcp.py

Comprehensive Test

python tests/comprehensive_test.py

Performance Test

python tests/test_performance_monitoring.py

🀝 Contributing

We welcome contributions from developers of all skill levels! This project thrives on community collaboration.

πŸš€ Quick Start for Contributors

# Fork and clone the repository
git clone https://github.com/yourusername/mcp-context-manager-python.git
cd mcp-context-manager-python

# Set up development environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

# Run development setup
python scripts/setup_dev.py

# Test your setup
python test_brain_mcp.py

πŸ“‹ Contribution Process

  1. 🍴 Fork the repository

  2. 🌿 Create a feature branch: git checkout -b feature/amazing-feature

  3. ✍️ Make your changes with tests and documentation

  4. βœ… Run the test suite: python -m pytest tests/

  5. πŸ“ Update documentation as needed

  6. πŸš€ Submit a Pull Request with a clear description

🎯 Areas for Contribution

🧠 Brain System Enhancements

  • New Memory Connection Types: Emotional, spatial, hierarchical connections

  • Advanced Memory Algorithms: Consolidation, decay, forgetting mechanisms

  • Knowledge Transfer: Cross-project memory sharing

  • Memory Classification: Improved categorization and tagging

🎨 Visualization & UI

  • Web-based Knowledge Graph: Interactive memory exploration

  • Real-time Analytics Dashboard: Live memory system insights

  • Memory Timeline: Historical view of knowledge growth

  • Learning Path Visualizations: Visual knowledge flow diagrams

πŸ”Œ Integrations & Extensions

  • VS Code Extension: Native IDE integration

  • JetBrains Plugins: IntelliJ, PyCharm support

  • Obsidian/Roam Connectors: Knowledge base integration

  • Slack/Discord Bots: Team collaboration features

πŸ“Š Analytics & Insights

  • Advanced Pattern Analysis: Memory usage analytics

  • Learning Recommendations: Personalized knowledge suggestions

  • Knowledge Gap Detection: Identify missing knowledge areas

  • Performance Optimization: Memory system tuning

🌍 Accessibility & Internationalization

  • Multi-language Support: Localized memory content

  • Accessibility Improvements: Screen reader support, keyboard navigation

  • Documentation Translations: Help translate guides and docs

  • Cultural Context: Domain-specific memory hierarchies

⚑ Performance & Scalability

  • Database Optimization: Query performance improvements

  • Distributed Systems: Multi-node memory sharing

  • Caching Strategies: Memory access optimization

  • Cloud Deployment: AWS, GCP, Azure support

🏷️ Issue Labels

We use these labels to help contributors find suitable tasks:

  • good first issue - Perfect for new contributors

  • help wanted - Looking for contributors

  • brain-system - Brain memory system features

  • visualization - UI and visualization work

  • integration - External system integrations

  • performance - Performance optimization

  • documentation - Documentation improvements

  • testing - Test coverage and quality

πŸ“š Resources for Contributors

πŸŽ‰ Recognition & Rewards

  • First Contribution Badge: Special recognition for first-time contributors

  • README Credits: All contributors listed in acknowledgments

  • Release Notes: Major contributions highlighted in releases

  • Maintainer Invitation: Active contributors invited to be maintainers

🀝 Community Support

  • GitHub Discussions: Ask questions and share ideas

  • Code Reviews: Get feedback on your contributions

  • Pair Programming: Arrange coding sessions with maintainers

  • Mentorship: Get guidance from experienced contributors

Ready to contribute? Pick an issue, fork the repo, and let's build the future of AI memory together! 🧠✨

πŸ“‹ Roadmap

Near Term

  • Web-based knowledge graph visualization

  • Export/import knowledge structures

  • Multi-user collaboration features

  • Enhanced embedding models

Medium Term

  • LLM integration for memory summarization

  • Domain-specific memory hierarchies

  • Real-time collaboration

  • Advanced analytics dashboard

Long Term

  • Distributed memory systems

  • Cross-project knowledge sharing

  • AI-powered memory curation

  • Enterprise deployment options

🚨 Troubleshooting

Common Issues

Server Won't Start

# Check Python version
python --version  # Should be 3.10+

# Test imports
python -c "from src.brain_enhanced_mcp_server import BrainEnhancedMCPServer"

# Check logs
tail -f logs/mcp_server.log

MCP Connection Issues

  1. Restart your MCP client completely

  2. Verify configuration paths are correct

  3. Check that Python virtual environment is activated

  4. Review client-specific MCP setup guides

Performance Issues

# Check performance metrics
python -c "
from src.performance_monitor import PerformanceMonitor
monitor = PerformanceMonitor('data/mcp_performance.db')
print(monitor.get_performance_report())
"

Memory Search Not Working

  • Ensure embeddings are generated (check logs)

  • Verify similarity thresholds in configuration

  • Test with different query terms

Getting Help

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Model Context Protocol - For the excellent protocol specification

  • Anthropic - For Claude and MCP development

  • Cursor - For MCP integration and development tools

  • Community Contributors - For feedback, testing, and improvements

πŸ“Š Project Status

  • βœ… Core Functionality: Complete and stable

  • βœ… Brain Features: Fully implemented and tested

  • βœ… MCP Compliance: Full protocol support

  • βœ… Documentation: Comprehensive guides available

  • βœ… Testing: Extensive test coverage

  • πŸš€ Production Ready: Stable and performant


Transform your AI agent from a simple chatbot into an intelligent partner with human-like memory and reasoning capabilities. 🧠✨

Built with ❀️ for the AI development community

Available Tools

16 tools
auto_inject_contextC

Automatically inject context for new conversation sessions

Inputs: project_id, max_memories, include_recent, use_ai_crafting, +1 more.

craft_ai_promptC

Craft an intelligent AI prompt using context summary and user input

Inputs: project_id (required), focus_areas, prompt_type, user_message.

fetch_memoryC

Fetch memories based on search criteria

Inputs: tags, limit, query, project_id, +1 more.

get_agent_statsC

Get statistics for an agent

Inputs: agent_id (required), project_id.

get_context_summaryC

Generate a context summary for chat session injection

Inputs: project_id, focus_areas, max_memories, include_recent.

get_knowledge_graphC

Get interconnected knowledge graph for a topic or project

Inputs: center_topic (required), max_depth, project_id, connection_types.

get_memory_insightsC

Get insights about knowledge patterns, growth, and recommendations

Inputs: project_id, include_recommendations.

get_performance_reportC

Get performance metrics and recommendations

Inputs: days, include_recommendations.

promote_memory_knowledgeC

Manually promote important memories and update knowledge structures

Inputs: memory_ids (required), target_layer, emotional_weight.

push_memoryC

Push a memory entry to the server

Inputs: content (required), tags, priority, project_id, +1 more.

record_feedbackC

Record user feedback about context injection

Inputs: rating (required), comment, project_id, context_summary.

register_agentD

Register a new agent

Inputs: name (required), agent_type, project_id.

search_similar_experiencesC

Find similar past experiences and related knowledge using brain-like memory search

Inputs: query (required), project_id, focus_areas, include_analogies.

start_conversation_recordingC

Start automatic conversation recording for a project

Inputs: project_id, auto_record_ai_responses, auto_record_user_messages.

stop_conversation_recordingB

Stop automatic conversation recording and create summary

Inputs: project_id.

trace_knowledge_pathC

Trace how knowledge flows from one concept to another through memory connections

Inputs: to_concept (required), from_concept (required), max_hops, project_id.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers