Skip to main content

MCP server that maintains project context (decisions, pipelines, constraints) across Claude conversations

Project description

Context Keeper

Project memory for Claude. Records design decisions, pipeline flows, and constraints so Claude maintains context across conversations.

The Problem

As conversations get long, Claude loses the "why" behind earlier decisions. New conversations start blank. This causes Claude to make changes that break established patterns — like rewriting a pipeline step it doesn't remember exists.

The Solution

Context Keeper gives Claude 8 tools to record and retrieve structured project context:

Tool Purpose
record_decision Save a decision with rationale and alternatives
record_pipeline Save a multi-step workflow with ordering
record_constraint Save a rule with scope and enforcement level
get_context Retrieve relevant entries by query, tags, scope, or ID
get_project_summary Compact overview for conversation start
update_entry Update any entry by ID
deprecate_entry Retire an entry with reason
prune_stale Find entries not verified recently
get_compaction_report Check if last compaction lost any context

All data stored as human-editable JSON files in .context/ inside your project directory. Zero external dependencies.

Install

pip install context-keeper

Claude Code

claude mcp add --scope user context-keeper -- python /path/to/context-keeper/server.py

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "context-keeper": {
      "command": "python",
      "args": ["/path/to/context-keeper/server.py"],
      "env": {
        "CONTEXT_KEEPER_PROJECT": "/path/to/your/project"
      }
    }
  }
}

Set CONTEXT_KEEPER_PROJECT to the root of your project. If omitted, it uses the current working directory.

How It Works

Recording Context

When you make a design decision:

You: Let's use JSON files instead of SQLite for storage.
Claude: [calls record_decision with summary, rationale, and alternatives]

When you establish a workflow:

You: The deploy pipeline is: run tests, build, push to registry, deploy.
Claude: [calls record_pipeline with ordered steps]

When you set a rule:

You: Never run Conductor from source. Always use the exe.
Claude: [calls record_constraint with rule, reason, and hardness=absolute]

Retrieving Context

At conversation start, Claude calls get_project_summary to see all active decisions, pipelines, and constraints. Before making changes, it calls get_context with relevant tags to check for conflicts.

Relevance Scoring

Without embeddings or external services, Context Keeper scores entries using:

  • Tag match — overlap between query and entry tags
  • Text match — query words found in summary/rationale/rule text
  • Recency — recently verified entries score higher
  • Status — active entries prioritized over superseded

Results are capped by a configurable token budget (default: 4000 tokens).

Claude Code Hook Setup

Context Keeper includes hooks that snapshot your context before Claude Code compaction and detect if anything was lost afterward.

Add to your Claude Code hooks config (~/.claude/settings.json):

{
  "hooks": {
    "PreCompact": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "python /path/to/context-keeper/hooks/pre_compact.py"
          }
        ]
      }
    ],
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "python /path/to/context-keeper/hooks/post_compact.py"
          }
        ]
      }
    ]
  }
}

Replace /path/to/context-keeper with the actual install path. Set CONTEXT_KEEPER_PROJECT env var if your project isn't in the current working directory.

At session start, Claude calls get_compaction_report to check if the last compaction lost any context entries. If discrepancies are found, they're surfaced before any work begins.

Data Storage

your-project/
  .context/
    decisions.json           # Design decisions with rationale
    pipelines.json           # Multi-step workflows
    constraints.json         # Rules and invariants
    config.json              # Token budget, stale threshold
    compaction_snapshot.json  # Pre-compaction snapshot (auto-generated)
    compaction_report.json   # Post-compaction diff report (auto-generated)
    hook.log                 # Hook activity log

All files are human-readable JSON. You can edit them directly. IDs are sequential and readable: dec-001, pipe-001, con-001.

Configuration

Create .context/config.json to customize:

{
  "project_name": "my-project",
  "token_budget": 4000,
  "max_entry_tokens": 1000,
  "stale_threshold_days": 30
}

Cross-Project Context

Query another project's context by passing project_dir:

Claude: [calls get_context with project_dir="/path/to/other-project"]

Or tag entries with other project names for cross-referencing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_keeper_mcp-0.1.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_keeper_mcp-0.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file context_keeper_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: context_keeper_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for context_keeper_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ae310321d75ebb67b7e41fd85cc0871c4892bc7e9430df55497b955bbb8fda8
MD5 43433883b55e6b2075fab68de3a32a64
BLAKE2b-256 e882e0b4810c9b7e78e3543cc7f3a14d0c4d72fe5b78906cbb17d6a57d265ea2

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_keeper_mcp-0.1.0.tar.gz:

Publisher: publish.yml on jarmstrong158/context-keeper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file context_keeper_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for context_keeper_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67e98f78dbe85a508c0b5601f5b38e87dd8e94e48849fb4c18f3b70f802aa828
MD5 87c9f250d0f76186e66904071bf83a7e
BLAKE2b-256 0bdac43226090606c806215644fdc590a67a34966e0cf0000aaea8af9522fa79

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_keeper_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on jarmstrong158/context-keeper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page