npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-praetorian-mcp

v1.0.0

Published

Aggressive context compaction MCP server for Claude Code - save and retrieve structured snapshots with 90%+ token savings

Readme

claude-praetorian-mcp

claude-historian-mcp

A Model Context Protocol (MCP) server for aggressive context compaction in Claude Code. Save 90%+ tokens by compacting web research, task outputs, and conversations into beautiful, structured snapshots.

npm version License: MIT TypeScript Node.js GitHub stars Claude

Inspired by this talk by Dexter Horthy from HumanLayer, and his team's work on ACE: Advanced Context Engineering for Coding Agents, 12-Factor Agents & the recent release of the TOON (Token-Oriented Object Notation) Format.

install

Requirements:

npm install -g claude-praetorian-mcp

From shell:

claude mcp add claude-praetorian-mcp -- bunx claude-praetorian-mcp

From inside Claude (restart required):

Add this to our global mcp config: bunx claude-praetorian-mcp

Install this mcp: https://github.com/Vvkmnn/claude-praetorian-mcp

From any manually configurable mcp.json: (Cursor, Windsurf, etc.)

{
  "mcpServers": {
    "praetorian": {
      "command": "bunx",
      "args": ["claude-praetorian-mcp"],
      "env": {}
    }
  }
}

features

MCP server for aggressive context compaction. Generates structured incremental snapshots to yield 90%+ token savings and easily refresh context with "frequent intentional compaction".

Currently runs project by project and saves artifacts to {$project}/.claude/praetorian via the following tools (and a royal guard ⚜️):

praetorian_compact

(Incrementally) compact context using the TOON format to get the most valuable tokens from an activity.

⚜️ praetorian_compact type=<type> title=<title>
  > "ACE Framework research - save 1,450 tokens"
  > "Icon rendering bug investigation - compact the findings"
  > "Database architecture decisions - preserve the rationale"
  > "WebFetch results from authentication docs"
  > "Task output from explore subagent - code structure analysis"
⚜️ compact | Created

┌─ ⚜️  ────────────────────────────────────────────────── Created ─┐
│ Compacted: "ACE Framework Research" • 1,450 tokens saved
│ Type: web_research • ID: cpt_1765245902396_nxetoc
└───────────────────────────────────────────────────────────────────┘
⚜️ compact | Merged

┌─ ⚜️  ───────────────────────────────────────────────────── Merged ─┐
│ Compacted: "Authentication Patterns" • 890 tokens saved
│ Type: decisions • ID: cpt_1765245903512_xk9mp1
│ Merged with: cpt_1765245903512_xk9mp1
└────────────────────────────────────────────────────────────────────┘

praetorian_restore

Search and restore context by injecting TOON tokens back into current context as needed.

⚜️ praetorian_restore query=<query>
  > "What did we learn about authentication?"
  > "Find the Docker container debugging session"
  > "Show recent architecture decisions"
  > "Search for MCP server implementation patterns"
  > "" (empty = recent compactions)
⚜️ restore | Search

┌─ ⚜️  ───────────────────────────────────────────────────── Search ─┐
│ Found 2 compactions
│ Query: "authentication"
└────────────────────────────────────────────────────────────────────┘
⚜️ restore | Recent

┌─ ⚜️  ───────────────────────────────────────────────────── Recent ─┐
│ Found 3 compactions
└────────────────────────────────────────────────────────────────────┘

Status indicators:

  • Created - New compaction saved
  • Merged - Updated existing compaction (>70% title similarity)
  • Search - Search results returned (keyword matching)
  • Recent - Recent compactions listed (by updated time)

usage

Praetorian is designed for heavy, frequent use. The more you compact, the more you save.

When to compact:

  • ✅ After every WebFetch
  • ✅ After every Task/subagent completes
  • ✅ After reading multiple files
  • ✅ After making decisions
  • ✅ During long conversations (proactive compaction)
  • ✅ Before context gets >60% full

Real-world example session:

| Compaction | Before | After | Saved | | --------------------- | ---------- | --------- | ---------------- | | Web research (3 URLs) | 4,500 | 300 | 4,200 | | Subagent outputs (2) | 3,500 | 300 | 3,200 | | Architecture debates | 5,000 | 300 | 4,700 | | Hook research | 1,500 | 150 | 1,350 | | Total | 14,500 | 1,050 | 13,450 (93%) |

Next session: restore() loads ~1,000 tokens. Instant resume, no re-research.

methodology

How claude-praetorian-mcp works:

                        claude-praetorian-mcp
              ======================================


  praetorian_compact (write)
  --------------------------

  INPUT ──> VALIDATE ──> DETECT ──> MERGE ──> ENCODE ──> INDEX ──> OUTPUT
              │            │          │         │          │
              │            │          │         │          └─ words -> IDs
              │            │          │         └─ .toon (30-60% smaller)
              │            │          └─ dedupe arrays, combine objects
              │            └─ Jaccard similarity > 70% = auto-merge
              └─ Zod schemas (CompactInput, Compaction)


  praetorian_restore (read)
  -------------------------

                      ┌─────────┐
  QUERY ──> SEARCH ───┤         ├──> DECODE ──> OUTPUT
                      │  INDEX  │
  (none) ──> RECENT ──┤         │
                      └─────────┘


  Storage: .claude/praetorian/
  ----------------------------

  index.json          Inverted word index + compaction metadata
  compactions/*.toon  TOON-encoded compaction files

Core optimizations:

File access:

  • Stores in: <project>/.claude/praetorian/
  • TOON format: .toon files (40% fewer bytes than YAML/XML)
  • Zero database dependencies (no db calls or filesystem)
  • Never leaves your machine

development

git clone https://github.com/Vvkmnn/claude-praetorian-mcp && cd claude-praetorian-mcp
npm install && npm run build

Package requirements:

  • Node.js: >=20.0.0 (ES modules)
  • npm: >=10.0.0 (package-lock v3)
  • Runtime: @modelcontextprotocol/sdk, @toon-format/toon, zod
  • Zero external databases - works with bunx

Development workflow:

npm run build          # TypeScript compilation
npm run watch          # Watch mode with tsc --watch
node dist/index.js     # Run MCP server directly (stdio)

Contributing:

  • Fork the repository and create feature branches
  • Test with multiple compaction types before submitting PRs
  • Follow TypeScript strict mode and MCP protocol

license

MIT


Emperor Claudius Tiberius Claudius Caesar Augustus Germanicus - Declared emperor by his Praetorian Guard