MCP server for Claude session management and conversation memory
Project description
Session Management MCP Server
A dedicated MCP server that provides comprehensive session management functionality for Claude Code sessions across any project.
Features
- ๐ Session Initialization: Complete setup with UV dependency management, project analysis, and automation tools
- ๐ Quality Checkpoints: Mid-session quality monitoring with workflow analysis and optimization recommendations
- ๐ Session Cleanup: Comprehensive cleanup with learning capture and handoff file creation
- ๐ Status Monitoring: Real-time session status and project context analysis
- โก Auto-Generated Shortcuts: Automatically creates
/start,/checkpoint, and/endClaude Code slash commands
๐ Automatic Session Management (NEW!)
For Git Repositories:
- โ Automatic initialization when Claude Code connects
- โ Automatic cleanup when session ends (quit, crash, or network failure)
- โ Intelligent auto-compaction during checkpoints
- โ Zero manual intervention required
For Non-Git Projects:
- ๐ Use
/startfor manual initialization - ๐ Use
/endfor manual cleanup - ๐ Full session management features available on-demand
The server automatically detects git repositories and provides seamless session lifecycle management with crash resilience and network failure recovery. Non-git projects retain manual control for flexible workflow management.
Available MCP Tools
Total: 70+ specialized tools organized into 10 functional categories:
๐ฏ Core Session Management (8 tools)
start- Comprehensive session initialization with project analysis, UV sync, and memory setupcheckpoint- Mid-session quality assessment with V2 scoring system and workflow analysisend- Complete session cleanup with learning capture and handoff documentationstatus- Current session overview with health checks and diagnosticspermissions- Manage trusted operations to reduce permission promptsauto_compact- Automatic context window compaction when neededquality_monitor- Real-time quality monitoring and trackingsession_welcome- Session connection information and continuity
๐ง Memory & Conversation Search (14 tools)
Semantic Search & Retrieval:
reflect_on_past/search_reflections- Semantic search through past conversations using local AI embeddings (all-MiniLM-L6-v2)quick_search- Fast overview search with count and top resultssearch_summary- Aggregated insights without individual resultsget_more_results- Pagination support for large result sets
Targeted Search:
search_by_file- Find conversations about specific filessearch_by_concept- Search for development concepts and patternssearch_code- Code-specific search with pattern matchingsearch_errors- Search error patterns and resolutionssearch_temporal- Time-based search queries
Storage & Management:
store_reflection- Store insights with tagging and embeddingsreflection_stats- Memory system statistics and healthreset_reflection_database- Reset/rebuild memory database
Advanced:
_optimize_search_results- Token-aware result optimization
๐ Crackerjack Quality Integration (11 tools)
Command Execution:
execute_crackerjack_command/crackerjack_run- Execute crackerjack with analyticscrackerjack_help- Comprehensive help for choosing commands
Metrics & Analysis:
crackerjack_metrics- Quality metrics trends over timecrackerjack_quality_trends- Trend analysis with actionable insightsget_crackerjack_quality_metrics- Detailed quality metric extractionget_crackerjack_results_history- Command execution history
Pattern Detection:
crackerjack_patterns- Test failure pattern analysisanalyze_crackerjack_test_patterns- Deep test pattern analysiscrackerjack_history- Execution history with trends
Health & Status:
crackerjack_health_check- Integration health diagnostics
๐ค LLM Provider Management (5 tools)
list_llm_providers- List available LLM providers and modelstest_llm_providers- Test provider availability and functionalitygenerate_with_llm- Generate text using specified providerchat_with_llm- Have conversations with LLM providersconfigure_llm_provider- Configure provider credentials and settings
โ๏ธ Serverless Session Management (8 tools)
create_serverless_session- Create session with external storageget_serverless_session- Retrieve session stateupdate_serverless_session- Update session statedelete_serverless_session- Delete sessionlist_serverless_sessions- List sessions by user/projecttest_serverless_storage- Test storage backend availabilitycleanup_serverless_sessions- Clean up expired sessionsconfigure_serverless_storage- Configure storage backends (Redis, S3, local)
๐ฅ Team Collaboration & Knowledge Sharing (4 tools)
create_team- Create team for knowledge sharingsearch_team_knowledge- Search team reflections with access controlget_team_statistics- Team activity and statisticsvote_on_reflection- Vote on team reflections (upvote/downvote)
๐ Multi-Project Coordination (4 tools)
create_project_group- Create project groups for coordinationadd_project_dependency- Add dependency relationships between projectssearch_across_projects- Search conversations across related projectsget_project_insights- Cross-project insights and collaboration opportunities
๐ฑ Application & Activity Monitoring (5 tools)
start_app_monitoring- Start IDE and browser activity monitoringstop_app_monitoring- Stop activity monitoringget_activity_summary- Activity summary over time periodget_context_insights- Generate insights from development behaviorget_active_files- Get recently active files
๐ Interruption & Context Management (7 tools)
start_interruption_monitoring- Smart detection and context preservationstop_interruption_monitoring- Stop interruption monitoringcreate_session_context- Create session context snapshotpreserve_current_context- Preserve context during interruptionsrestore_session_context- Restore preserved session contextget_interruption_history- Interruption history and statisticsget_interruption_statistics- Comprehensive interruption stats
โฐ Natural Language Scheduling (5 tools)
create_natural_reminder- Create reminder from natural languagelist_user_reminders- List pending reminderscancel_user_reminder- Cancel specific reminderstart_reminder_service- Start background reminder servicestop_reminder_service- Stop reminder service
๐ณ Git Worktree Management (3 tools)
git_worktree_add- Create new git worktreegit_worktree_remove- Remove existing worktreegit_worktree_switch- Switch context between worktrees with session preservation
๐ Advanced Search Features (3 tools)
advanced_search- Faceted search with filteringsearch_suggestions- Search completion suggestionsget_search_metrics- Search and activity metrics
All tools use local processing for privacy, with DuckDB vector storage (FLOAT[384] embeddings) and ONNX-based semantic search requiring no external API calls.
๐ Integration with Crackerjack
Session-mgmt includes deep integration with Crackerjack, the AI-driven Python development platform:
Integrated Features:
- ๐ Quality Metrics Tracking: Automatically captures and tracks Crackerjack quality scores over time
- ๐งช Test Result Monitoring: Learns from test patterns, failures, and successful fixes
- ๐ Error Pattern Recognition: Remembers how specific errors were resolved and suggests solutions
- ๐ Command History Analysis: Tracks which Crackerjack commands are most effective for different scenarios
- ๐ฏ Progress Intelligence: Predicts completion times based on historical data
Why Use Both Together:
- Crackerjack: Enforces code quality, runs tests, manages releases, and provides AI auto-fixing
- Session-mgmt: Remembers what worked, tracks progress evolution, and maintains context
- Synergy: Creates an intelligent development environment that learns from every interaction
Example Integrated Workflow:
- ๐ Session-mgmt
start- Sets up your session with accumulated context from previous work - ๐ง Crackerjack runs quality checks and applies AI agent fixes to resolve issues
- ๐พ Session-mgmt captures successful patterns, quality improvements, and error resolutions
- ๐ง Next session starts with all accumulated knowledge and learned patterns
- ๐ Continuous improvement as both systems get smarter with each interaction
Technical Integration:
The crackerjack_integration.py module (50KB+) provides:
- Real-time progress tracking during Crackerjack operations
- Quality metric extraction and trend analysis
- Test result pattern detection and storage
- Error resolution pattern matching for faster fixes
- Command effectiveness scoring for workflow optimization
Configuration Example:
{
"mcpServers": {
"crackerjack": {
"command": "python",
"args": ["-m", "crackerjack", "--start-mcp-server"]
},
"session-mgmt": {
"command": "python",
"args": ["-m", "session_mgmt_mcp.server"]
}
}
}
The integration is automatic once both servers are configured - they coordinate through the MCP protocol without requiring additional setup.
Crackerjack MCP Tool Usage
When using Crackerjack through MCP tools, follow these patterns for correct usage:
โ Correct Usage
# Run tests with AI auto-fix
await crackerjack_run(command="test", ai_agent_mode=True)
# Run all checks with verbose output
await crackerjack_run(
command="check",
args="--verbose",
ai_agent_mode=True,
timeout=600, # 10 minutes for complex fixes
)
# Dry-run to preview fixes
await crackerjack_run(command="test", args="--dry-run", ai_agent_mode=True)
# Run security checks
await execute_crackerjack_command(command="security")
# Run with custom iteration limit
await crackerjack_run(command="test", args="--max-iterations 15", ai_agent_mode=True)
โ Common Mistakes
# WRONG - Don't put flags in command parameter
await crackerjack_run(command="--ai-fix -t")
# WRONG - Don't put --ai-fix in args
await crackerjack_run(command="test", args="--ai-fix")
# WRONG - Don't use CLI flag syntax
await execute_crackerjack_command(command="-t --verbose")
# CORRECT
await crackerjack_run(command="test", ai_agent_mode=True)
Parameters
-
command(required): Semantic command name- Valid:
test,lint,check,format,security,complexity,all - Invalid:
--ai-fix,-t, any CLI flags
- Valid:
-
ai_agent_mode(optional, default False): Enable AI-powered auto-fix- Replaces the
--ai-fixCLI flag - Requires Anthropic API key configured in crackerjack
- Max 10 iterations by default (configurable via
--max-iterationsin args)
- Replaces the
-
args(optional): Additional arguments- Examples:
--verbose,--dry-run,--max-iterations 5 - Do NOT include
--ai-fixhere - useai_agent_mode=Trueinstead
- Examples:
-
working_directory(optional, default "."): Working directory for command execution -
timeout(optional, default 300): Timeout in seconds- Increase for complex auto-fix operations (e.g., 600-1200 seconds)
Auto-Fix Workflow
When ai_agent_mode=True, Crackerjack will:
- Run pre-commit hooks and detect issues
- Apply AI-powered fixes using Claude AI
- Re-run hooks to verify fixes
- Iterate up to 10 times (or custom
--max-iterations) until convergence - Stop when all hooks pass or no progress can be made
Configuration Requirements:
# 1. Set API key
export ANTHROPIC_API_KEY=sk-ant-...
# 2. Configure adapter in settings/adapters.yml
ai: claude
See Crackerjack AUTO_FIX_GUIDE.md for detailed auto-fix documentation.
Installation
From Source
# Clone the repository
git clone https://github.com/lesleslie/session-mgmt-mcp.git
cd session-mgmt-mcp
# Install dependencies
uv sync --group dev
# Or use pip
pip install -e ".[embeddings,dev]"
MCP Configuration
Add to your project's .mcp.json file:
{
"mcpServers": {
"session-mgmt": {
"command": "python",
"args": ["-m", "session_mgmt_mcp.server"],
"cwd": "/path/to/session-mgmt-mcp",
"env": {
"PYTHONPATH": "/path/to/session-mgmt-mcp"
}
}
}
}
Alternative: Use Script Entry Point
If installed with pip/uv, you can use the script entry point:
{
"mcpServers": {
"session-mgmt": {
"command": "session-mgmt-mcp",
"args": [],
"env": {}
}
}
}
Dependencies
Core Requirements (from pyproject.toml):
- Python 3.13+
fastmcp>=2- MCP server frameworkduckdb>=0.9- Conversation storage with vector supportnumpy>=1.24- Numerical operations for embeddingspydantic>=2.0- Data validation and settings managementtiktoken>=0.5- Token counting and optimizationcrackerjack- Code quality and testing integrationonnxruntime>=1.15- Local ONNX model inferencetransformers>=4.21- Tokenizer for embedding modelspsutil>=7.0.0- System and process utilitiesrich>=14.1.0- Terminal formatting and outputstructlog>=25.4- Structured loggingpydantic-settings>=2.0- Settings managementtomli>=2.2.1- TOML parsingtyper>=0.17.4- CLI interface
Development Dependencies (install with --group dev):
pytest>=7+pytest-asyncio>=0.21- Testing frameworkpytest-cov>=4,pytest-benchmark>=4- Coverage and benchmarkingpytest-xdist>=3,pytest-timeout>=2.1- Parallel execution and timeoutshypothesis>=6.70- Property-based testingcoverage>=7- Code coverage analysispytest-mock>=3.10- Mocking utilitiespsutil>=5.9- Process monitoring
Install all dependencies:
# Full installation with development tools
uv sync --group dev
# Minimal installation (production)
uv sync
# From PyPI with pip
pip install session-mgmt-mcp
Usage
Once configured, the following slash commands become available in Claude Code:
Primary Session Commands
/session-mgmt:start- Full session initialization with workspace verification/session-mgmt:checkpoint- Quality monitoring checkpoint with scoring/session-mgmt:end- Complete session cleanup with learning capture/session-mgmt:status- Current status overview with health checks
Auto-Generated Shortcuts
The first time you run /session-mgmt:start, convenient shortcuts are automatically created:
/startโ/session-mgmt:start- Quick session initialization/checkpoint [name]โ/session-mgmt:checkpoint- Create named checkpoints/endโ/session-mgmt:end- Quick session cleanup
These shortcuts are created in
~/.claude/commands/and work across all projects
Memory & Search Commands
/session-mgmt:reflect_on_past- Search past conversations with semantic similarity/session-mgmt:store_reflection- Store important insights with tagging/session-mgmt:quick_search- Fast search with overview results/session-mgmt:permissions- Manage trusted operations
Advanced Usage
Running Server Directly (for development):
python -m session_mgmt_mcp.server
# or
session-mgmt-mcp
Testing Memory Features:
# The memory system automatically stores conversations and provides:
# - Semantic search across all past conversations
# - Local embedding generation (no external API needed)
# - Cross-project conversation history
# - Time-decay prioritization for recent content
Memory System Architecture
Built-in Conversation Memory
- Local Storage: DuckDB database at
~/.claude/data/reflection.duckdb - Embeddings: Local ONNX models (all-MiniLM-L6-v2) for semantic search
- Vector Storage: FLOAT[384] arrays for similarity matching
- No External Dependencies: Everything runs locally for privacy
- Cross-Project History: Conversations tagged by project context
Search Capabilities
- Semantic Search: Vector similarity with customizable thresholds
- Text Fallback: Standard text search when embeddings unavailable
- Time Decay: Recent conversations prioritized in results
- Project Context: Filter searches by project or search across all
- Batch Operations: Efficient bulk storage and retrieval
Data Storage
This server manages its data locally in the user's home directory:
- Memory Storage:
~/.claude/data/reflection.duckdb - Session Logs:
~/.claude/logs/ - Configuration: Uses pyproject.toml and environment variables
Recommended Session Workflow
-
Initialize Session:
/session-mgmt:start- UV dependency synchronization
- Project context analysis and health monitoring
- Session quality tracking setup
- Memory system initialization
- Permission system setup
-
Monitor Progress:
/session-mgmt:checkpoint(every 30-45 minutes)- Real-time quality scoring
- Workflow optimization recommendations
- Progress tracking and goal alignment
- Automatic Git checkpoint commits
-
Search Past Work:
/session-mgmt:reflect_on_past- Semantic search through project history
- Find relevant past conversations and solutions
- Build on previous insights
-
Store Important Insights:
/session-mgmt:store_reflection- Capture key learnings and solutions
- Tag insights for easy retrieval
- Build project knowledge base
-
End Session:
/session-mgmt:end- Final quality assessment
- Learning capture across categories
- Session handoff file creation
- Memory persistence and cleanup
Benefits
Comprehensive Coverage
- Session Quality: Real-time monitoring and optimization
- Memory Persistence: Cross-session conversation retention
- Project Structure: Context-aware development workflows
Reduced Friction
- Single Command Setup: One
/session-mgmt:startsets up everything - Local Dependencies: No external API calls or services required
- Intelligent Permissions: Reduces repeated permission prompts
- Automated Workflows: Structured processes for common tasks
Enhanced Productivity
- Quality Scoring: Guides session effectiveness
- Built-in Memory: Enables building on past work automatically
- Project Templates: Accelerates development setup
- Knowledge Persistence: Maintains context across sessions
Documentation
The project documentation is organized into the following categories:
For Developers
- Testing Guide - Comprehensive testing strategy, status, and standards
- Parameter Validation - Pydantic parameter validation guide
- Architecture - System architecture and design patterns
- Integration - Integration patterns and best practices
For Users
- Quick Start - Getting started guide
- Configuration - Setup and configuration options
- Deployment - Deployment and production setup
- MCP Tools Reference - Complete tool documentation
Features
- AI Integration - AI integration strategies and patterns
- Token Optimization - Token management and chunking features
- Auto Lifecycle - Automatic session management
- Crackerjack Integration - Comprehensive code quality integration
- Selective Auto-Store - Smart reflection storage
Reference
- MCP Schema Reference - MCP protocol schemas
- Slash Command Shortcuts - Command reference
Troubleshooting
Common Issues
- Memory not working: Install optional dependencies with
pip install "session-mgmt-mcp[embeddings]" - Path errors: Ensure
cwdandPYTHONPATHare set correctly in.mcp.json - Permission issues: Use
/session-mgmt:permissionsto trust operations - Project context: Analyze current project health and structure
Debug Mode
# Run with verbose logging
PYTHONPATH=/path/to/session-mgmt-mcp python -m session_mgmt_mcp.server --debug
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file session_mgmt_mcp-0.7.1.tar.gz.
File metadata
- Download URL: session_mgmt_mcp-0.7.1.tar.gz
- Upload date:
- Size: 678.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0f6309e686a2bf47664d8f637d25bd727279883236a0ef74e14960b6be722d9
|
|
| MD5 |
cfaae37fd2ed841908222df94726d8c9
|
|
| BLAKE2b-256 |
f08d37c37a471259b6458e72707661944a008154792faeb650c3e8c2ab8fc17b
|
File details
Details for the file session_mgmt_mcp-0.7.1-py3-none-any.whl.
File metadata
- Download URL: session_mgmt_mcp-0.7.1-py3-none-any.whl
- Upload date:
- Size: 273.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30ddfae2a067e86dcb8edf4e07f741df64f45eafa75fe9e648a80b1a110420b9
|
|
| MD5 |
2af39e48aa976b347c2f91420d99d8af
|
|
| BLAKE2b-256 |
6b9a745ca6b52d7c00f42d9b2971145c7c73da0a81421e7666647f9549f31dab
|