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"
          }
        ]
      }
    ],
    "SessionStart": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "python -c \"print('[Context Keeper] At session start: call get_compaction_report first, then get_project_summary. Record new decisions, pipelines, and constraints as they happen.')\""
          }
        ]
      }
    ]
  }
}

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.

Windows users: Use forward slashes (C:/Users/.../context-keeper/hooks/pre_compact.py) or double-escaped backslashes in JSON. Single backslashes get mangled by the shell.

The hooks do three things:

  • PreCompact — snapshots all active .context/ entries before Claude Code compaction
  • Stop — compares post-compaction state against the snapshot, writes a diff report if anything changed
  • SessionStart — reminds Claude to call get_compaction_report and get_project_summary at the start of every new session

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.1.tar.gz (13.9 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.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: context_keeper_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 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.1.tar.gz
Algorithm Hash digest
SHA256 e4e48adb580b3fc5f599d7eeb7435c228033d7f1b7285f6db40f3b536d3b7cf2
MD5 fd41ba6afb63f63c12390f63bd758bf8
BLAKE2b-256 cb91e417efcfad60b086881f907cf5e64db88fe7741363fff01b936f650ff507

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_keeper_mcp-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for context_keeper_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca7afd1447b2fed894fdc40a1007b83eb5df8c6cd57266f82f37f5ba042529c7
MD5 2743afa257eb417ab469fc4290b3bc6b
BLAKE2b-256 5d0763baf449f0f0c6badb27bdb11aafff94eb8f83b96bd6001470a3a6b2d735

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_keeper_mcp-0.1.1-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