Works with the AI Agents you already use
MCP Context Compression Engine
Optimize MCP tool outputs and JSON payloads using semantic summarization and schema pruning to reduce token costs.
$15
MCP Context Compression Engine
Example session with this skill installed
I have a massive JSON payload from a GitHub MCP tool call that is hitting context limits. Prune the redundant metadata and give me a TypeScript filter function to handle this.
- Read your context and instructions
- Compiled the mcp context compression
I have analyzed the GitHub MCP tool output. The payload contains deep nesting of user objects and redundant repository permissions that are not required for the current reasoning task. I have applied JSON schema pruning to reduce the token footprint by approximately 68%.
MCP Context Compression Results
Token Reduction Metric:
- Original Payload: ~4,200 tokens
- Compressed Payload: ~1,344 tokens
- Savings: 68%
Optimized TypeScript Middleware
/**
* MCP Middleware: GitHub Repository Data Pruner
* Removes redundant metadata, null fields, and nested user details.
*/
export function pruneGithubPayload(rawData: any): any {
if (!rawData) return null;
// Define allowed keys to keep the context focused
const allowedRepoKeys = ['id', 'full_name', 'description', 'stargazers_count', 'language'];
const processRepo = (repo: any) => {
const pruned: any = {};
allowedRepoKeys.forEach(key => {
if (repo[key] !== undefined && repo[key] !== null) {
pruned[key] = repo[key];
}
});
return pruned;
};
if (Array.isArray(rawData)) {
return rawData.map(processRepo);
}
return processRepo(rawData);
}
Next steps
- Integrate the
pruneGithubPayloadfunction into your MCP tool handler. - Monitor the
evals/eval-suite.jsonto verify no critical data is lost during extraction. - Apply sliding window summarization if the conversation history exceeds 10 iterations.
Connects securely to your tools. The creator never sees your data.
About this skill
Large MCP tool outputs and deep JSON payloads quickly saturate LLM context windows, spiking costs and degrading reasoning quality. This skill implements deterministic compression techniques to strip redundancy and preserve critical signal for agentic workflows.
What it does
- JSON Schema Pruning removes null fields, redundant attributes, and deep nested metadata from raw tool responses.
- AST Summarization applies extractive scoring to large source files to retain logic while shedding token weight.
- Sliding Context Management archives older tool interactions into condensed semantic summaries to maintain long-running sessions.
- Middleware Generation produces clean TypeScript or Python functions specifically for MCP data filtering.
- Token Benchmarking provides metrics showing token reduction impact to validate efficiency gains.
How it works
- Analyze Payload by identifying deep nesting and redundant keys in the provided JSON or tool output.
- Apply Compression using pruning, AST-based summarization, or sliding window logic based on the data type.
- Generate Middleware code to automate this filtering in your MCP server or agent stack.
- Verify Efficiency by reviewing the token reduction metrics and semantic integrity report.
Frameworks & tools
Built for the Model Context Protocol (MCP) ecosystem. Compatible with Claude Code, Agent SDK v0.3+, Gemini CLI, Cursor, and Windsurf. Supports TypeScript and Python for middleware implementation.
Why this beats prompting it yourself
Manual prompts often fail to strip deep JSON metadata consistently or hallucinate when summarizing complex code structures. This skill uses deterministic pruning and AST-based logic to ensure >60% token reduction without losing the specific data points your agent needs to function.
Use cases
- Optimizing MCP tool calls that return massive database or API payloads.
- Managing long-form agent sessions where history length threatens context limits.
- Reducing inference latency and costs for high-frequency agentic swarms.
- Scaffolding data filters for custom MCP servers in TypeScript or Python.
Known limitations
Restricted to workspace-confined file operations within the active project directory. Requires project-scoped runners like npx or venv for execution.
Strictly restricted to the active project workspace. Cannot access parent directories or system-level paths. Requires project-scoped runners like npx, uvx, or venv.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 day ago
Requires
Permissions
Target Use Cases: - Compress large MCP tool outputs to save context window tokens. - Build context compression middleware for AI agent tool calls. - Prune redundant JSON data from LLM prompt context.