mcp-context-guard
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Context Guard — Context Window Management for AI Agents
Compress tool outputs, manage token budgets, deduplicate content, and filter by relevance. Zero dependencies, pure Python stdlib.
The Problem
AI agents waste context window tokens on:
Verbose tool outputs (file reads, search results, logs)
Duplicate content across tool calls
Irrelevant passages that don't match the task
Related MCP server: toonify-mcp
The Solution
MCP Context Guard sits between your tools and the LLM, compressing and filtering everything that enters the context window.
Tools (14)
Tool | What it does |
| Extractive summarization to N tokens |
| Set a total token budget |
| Check if text fits remaining budget |
| Deduct tokens from budget |
| Remove near-duplicate texts (Jaccard similarity) |
| Extract top-N key sentences |
| Truncate at sentence boundaries |
| Split into token-sized chunks with overlap |
| Estimate token count (word-based heuristic) |
| Compress conversation messages |
| BM25 relevance scoring, return top-K passages |
| Combine sources with dedup + compression |
| Context usage statistics |
| Reset all state |
Install
git clone https://github.com/aaameobius-crypto/mcp-context-guard.git
cd mcp-context-guard
python -m src.server --stdioTests
python -m pytest tests/ -v # 36 tests, all passingInspiration
headroom — 60-95% token reduction
context-mode — Intercept tool output
LLMLingua — Prompt compression
License
MIT — AMEOBIUS
Related MCP Connectors
Compress coding-agent context ~64%. Hosted Neural Keep MCP for Cursor/Claude/Codex.
Compress prose for LLM context windows. Per-call USDC billing, signed receipt.
Verified AI-agent outcomes: secret scanning, JSON cleanup, dedupe, anomaly and schema checks.
Up to 90% fewer tokens: deterministic, declared tool calls, each with a receipt and an audit trail.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn adaptive tiny-model layer that sits between an LLM and its MCP tools, compressing verbose tool outputs to reduce token usage by up to two orders of magnitude.1Apache 2.0
- AlicenseAqualityCmaintenanceContext compression plugin for Claude Code that automatically trims large tool outputs like JSON, CSV, and stack traces to save context window space.567MIT
- FlicenseNot gradedqualityDmaintenanceFilters verbose terminal output from commands like npm install, pip install, docker build, and pytest, reducing context token consumption for AI agents by condensing logs, removing progress bars, and grouping repeated warnings.-
- FlicenseAqualityDmaintenanceReduces token consumption by 73-87% by cleaning web and API data before it reaches the LLM context window. Supports fetching URLs, searching the web, optimizing JSON, and more.61-