Skip to main content
Glama

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

compress

Extractive summarization to N tokens

set_budget

Set a total token budget

check_budget

Check if text fits remaining budget

consume_budget

Deduct tokens from budget

deduplicate

Remove near-duplicate texts (Jaccard similarity)

extract_key

Extract top-N key sentences

truncate_smart

Truncate at sentence boundaries

chunk

Split into token-sized chunks with overlap

token_count

Estimate token count (word-based heuristic)

summarize_history

Compress conversation messages

filter_relevant

BM25 relevance scoring, return top-K passages

merge_context

Combine sources with dedup + compression

get_stats

Context usage statistics

reset

Reset all state

Install

git clone https://github.com/aaameobius-crypto/mcp-context-guard.git
cd mcp-context-guard
python -m src.server --stdio

Tests

python -m pytest tests/ -v  # 36 tests, all passing

Inspiration

License

MIT — AMEOBIUS

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An 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.
    1
    Apache 2.0
  • A
    license
    Not graded
    quality
    A
    maintenance
    Context compression plugin for Claude Code that automatically trims large tool outputs like JSON, CSV, and stack traces to save context window space.
    64
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Filters 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.
  • F
    license
    A
    quality
    C
    maintenance
    Reduces 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.
    6
    1

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aaameobius-crypto/mcp-context-guard'

If you have feedback or need assistance with the MCP directory API, please join our Discord server