trapper-keeper-mcp

asachs01/trapper-keeper-mcp

3.2

If you are the rightful owner of trapper-keeper-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Trapper Keeper MCP is an intelligent document extraction and organization system designed to keep your AI context organized efficiently.

Tools
  1. process_file

    Process a single file and extract categorized content.

  2. process_directory

    Process all matching files in a directory.

  3. watch_directory

    Start watching a directory for changes.

  4. stop_watching

    Stop watching a specific directory.

  5. list_watched_directories

    Get information about all watched directories.

  6. get_categories

    Get list of available extraction categories.

  7. update_config

    Update server configuration at runtime.

Trapper Keeper MCP

Keep your AI context organized like a boss ๐Ÿ“šโœจ

An intelligent document extraction and organization system built as a Model Context Protocol (MCP) server using Python and FastMCP. Trapper Keeper watches directories for markdown and text files, extracts categorized content, and organizes it into structured outputs.

๐Ÿ—๏ธ Architecture

Trapper Keeper MCP is designed with a modular, event-driven architecture that supports both CLI and MCP server modes:

Key Components

  • Core: Base classes, type definitions, and configuration management
  • Monitoring: File system monitoring with debouncing and pattern matching
  • Parser: Extensible document parsing (currently supports Markdown)
  • Extractor: Intelligent content extraction with category detection
  • Organizer: Flexible output organization and formatting
  • MCP Server: FastMCP-based server implementation
  • CLI: Rich command-line interface

โœ… Features

Intelligent Content Extraction

  • Category Detection: Automatically categorizes content using pattern matching and keywords
  • Importance Scoring: Assigns importance scores based on content relevance
  • Section Parsing: Preserves document structure with hierarchical sections
  • Code Block Extraction: Extracts and categorizes code snippets
  • Link Extraction: Groups and organizes document links

Real-time File Monitoring

  • Directory Watching: Monitors directories for file changes
  • Pattern Matching: Configurable file patterns and ignore rules
  • Debouncing: Prevents duplicate processing of rapid changes
  • Event System: Async event-driven architecture for scalability

Flexible Organization

  • Multiple Output Formats: Markdown, JSON, and YAML
  • Grouping Options: By category, document, or custom grouping
  • Index Generation: Automatic index creation with statistics
  • Metadata Preservation: Maintains source information and timestamps

๐Ÿ“‹ Setup

Prerequisites

  • Python 3.8 or higher
  • pip or poetry for dependency management

Installation

  1. Clone the repository:
git clone https://github.com/asachs01/trapper-keeper-mcp.git
cd trapper-keeper-mcp
  1. Install dependencies:
pip install -e .
  1. Copy the example configuration:
cp config.example.yaml config.yaml
  1. Edit config.yaml to match your needs

MCP Integration

Add to your MCP settings:

{
  "mcpServers": {
    "trapper-keeper": {
      "command": "python",
      "args": ["-m", "trapper_keeper.mcp.server"],
      "env": {
        "PYTHONPATH": "/path/to/trapper-keeper-mcp/src"
      }
    }
  }
}

๐ŸŒ API

CLI Commands

# Process a single file
trapper-keeper process document.md -o ./output

# Process a directory
trapper-keeper process ./docs -c "๐Ÿ—๏ธ Architecture" -c "๐Ÿ” Security" -f json

# Watch a directory
trapper-keeper watch ./docs -p "*.md" -p "*.txt" --recursive

# List categories
trapper-keeper categories

# Run as MCP server
trapper-keeper server

# Show/save configuration
trapper-keeper config
trapper-keeper config -o my-config.yaml

Category Configuration

The system uses emoji-prefixed categories for easy identification:

  • ๐Ÿ—๏ธ Architecture - System design and structure
  • ๐Ÿ—„๏ธ Database - Database schemas and queries
  • ๐Ÿ” Security - Authentication and security concerns
  • โœ… Features - Feature descriptions and requirements
  • ๐Ÿ“Š Monitoring - Logging and observability
  • ๐Ÿšจ Critical - Urgent issues and blockers
  • ๐Ÿ“‹ Setup - Installation and configuration
  • ๐ŸŒ API - API endpoints and integrations
  • ๐Ÿงช Testing - Test cases and strategies
  • โšก Performance - Optimization and speed
  • ๐Ÿ“š Documentation - Guides and references
  • ๐Ÿš€ Deployment - Deployment and CI/CD
  • โš™๏ธ Configuration - Settings and options
  • ๐Ÿ“ฆ Dependencies - Package management

MCP Tools Available

The MCP server exposes the following tools:

process_file

Process a single file and extract categorized content.

{
    "file_path": "/path/to/document.md",
    "extract_categories": ["๐Ÿ—๏ธ Architecture", "๐Ÿ” Security"],
    "output_format": "markdown"
}

process_directory

Process all matching files in a directory.

{
    "directory_path": "/path/to/docs",
    "patterns": ["*.md", "*.txt"],
    "recursive": true,
    "output_dir": "./output",
    "output_format": "json"
}

watch_directory

Start watching a directory for changes.

{
    "directory_path": "/path/to/docs",
    "patterns": ["*.md"],
    "recursive": true,
    "process_existing": true
}

stop_watching

Stop watching a specific directory.

list_watched_directories

Get information about all watched directories.

get_categories

Get list of available extraction categories.

update_config

Update server configuration at runtime.

๐Ÿ“Š Monitoring

Trapper Keeper includes Prometheus metrics for monitoring:

  • Files processed (success/failure counts)
  • Event publications by type
  • Content extraction by category
  • Processing duration histograms
  • Queue sizes and active watchers

Metrics are exposed on port 9090 by default.

๐Ÿšจ Critical Configuration

Environment Variables

  • TRAPPER_KEEPER_LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
  • TRAPPER_KEEPER_METRICS_PORT: Prometheus metrics port
  • TRAPPER_KEEPER_MCP_PORT: MCP server port
  • TRAPPER_KEEPER_OUTPUT_DIR: Default output directory
  • TRAPPER_KEEPER_MAX_CONCURRENT: Maximum concurrent file processing

๐Ÿ” Security

  • File access is restricted to configured paths
  • No remote code execution
  • Configurable ignore patterns for sensitive files
  • All file operations are read-only by default

Development

Project Structure

src/trapper_keeper/
โ”œโ”€โ”€ core/           # Base classes and types
โ”œโ”€โ”€ monitoring/     # File monitoring
โ”œโ”€โ”€ parser/         # Document parsers
โ”œโ”€โ”€ extractor/      # Content extraction
โ”œโ”€โ”€ organizer/      # Output organization
โ”œโ”€โ”€ mcp/           # MCP server
โ”œโ”€โ”€ cli/           # CLI interface
โ””โ”€โ”€ utils/         # Utilities

Adding a New Parser

  1. Create a new parser class inheriting from Parser
  2. Implement required methods: parse(), can_parse()
  3. Register in parser_factory.py

Adding a New Category

  1. Add to ExtractionCategory enum in types.py
  2. Add detection patterns in category_detector.py

Plugin System

The architecture supports plugins through the Plugin protocol. Plugins can:

  • Process documents
  • Add new extraction categories
  • Implement custom output formats

Why "Trapper Keeper"?

Named after the iconic 90s school organizer, Trapper Keeper MCP does for your code documentation what those colorful binders did for school papers - keeps everything organized, accessible, and prevents the chaos of loose papers (or in our case, sprawling documentation) from taking over your project.

Documentation

Getting Started

  • - Get up and running in 5 minutes
  • - Detailed installation instructions
  • - All configuration options

User Guides

  • - Complete CLI command reference
  • - Using MCP tools effectively
  • - Python API documentation
  • - Common issues and solutions

Tutorials

  • - Step-by-step tutorials
  • - Complex use cases
  • - Integrate with other tools
  • - Create custom categories

Architecture & Development

  • - System design
  • - How to contribute
  • - Extend functionality

Examples

  • - Configuration examples
  • - API usage examples
  • - Docker deployment examples
  • - Sample documentation files

License

MIT License - see LICENSE file for details.