Skip to main content
Glama
AiAgentKarl

Agent Context Optimizer MCP

by AiAgentKarl
README.md
# Agent Context Optimizer MCP ⚔

Solves the **#1 problem** with MCP servers: **context window overload**.

When you have 10+ MCP servers installed, their tool schemas can consume 40-50% of your context window — leaving less room for actual conversation. This server fixes that.

## What it does

- **Analyzes your task** and recommends only the servers you actually need
- **Estimates token usage** for any combination of servers
- **Optimizes your server set** by identifying which servers to unload
- **Suggests minimal configurations** for maximum context efficiency

## Installation

```bash
pip install agent-context-optimizer-mcp
```

## Usage with Claude Code

```json
{
  "mcpServers": {
    "optimizer": {
      "command": "uvx",
      "args": ["agent-context-optimizer-mcp"]
    }
  }
}
```

## Tools

| Tool | Description |
|------|-------------|
| `analyze_task` | Analyze a task and recommend optimal server combination |
| `estimate_context_usage` | Estimate context window consumption for servers |
| `get_server_catalog` | Full catalog of known MCP servers with categories |
| `optimize_server_set` | Optimize currently loaded servers for a task |
| `suggest_minimal_set` | Recommend the absolute minimum servers needed |

## Example

```
"I need to check the safety of a Solana token"
→ Recommends: solana (required)
→ Saves: 85% context tokens vs loading all servers
```

## Why this matters

- Average MCP server uses ~3,000 tokens for tool schemas
- 10 servers = ~30,000 tokens = 15% of a 200k context window
- 20 servers = ~60,000 tokens = 30% wasted on tool definitions
- This optimizer helps you load only what you need


---

## More MCP Servers by AiAgentKarl

| Category | Servers |
|----------|---------|
| šŸ”— Blockchain | [Solana](https://github.com/AiAgentKarl/solana-mcp-server) |
| šŸŒ Data | [Weather](https://github.com/AiAgentKarl/weather-mcp-server) Ā· [Germany](https://github.com/AiAgentKarl/germany-mcp-server) Ā· [Agriculture](https://github.com/AiAgentKarl/agriculture-mcp-server) Ā· [Space](https://github.com/AiAgentKarl/space-mcp-server) Ā· [Aviation](https://github.com/AiAgentKarl/aviation-mcp-server) Ā· [EU Companies](https://github.com/AiAgentKarl/eu-company-mcp-server) |
| šŸ”’ Security | [Cybersecurity](https://github.com/AiAgentKarl/cybersecurity-mcp-server) Ā· [Policy Gateway](https://github.com/AiAgentKarl/agent-policy-gateway-mcp) Ā· [Audit Trail](https://github.com/AiAgentKarl/agent-audit-trail-mcp) |
| šŸ¤– Agent Infra | [Memory](https://github.com/AiAgentKarl/agent-memory-mcp-server) Ā· [Directory](https://github.com/AiAgentKarl/agent-directory-mcp-server) Ā· [Hub](https://github.com/AiAgentKarl/mcp-appstore-server) Ā· [Reputation](https://github.com/AiAgentKarl/agent-reputation-mcp-server) |
| šŸ”¬ Research | [Academic](https://github.com/AiAgentKarl/crossref-academic-mcp-server) Ā· [LLM Benchmark](https://github.com/AiAgentKarl/llm-benchmark-mcp-server) Ā· [Legal](https://github.com/AiAgentKarl/legal-court-mcp-server) |

[→ Full catalog (40+ servers)](https://github.com/AiAgentKarl)

## License

MIT

TDQS

A3.5/5.0

Scored across 5 tools

Disambiguation4/5

Tools are mostly distinct: analyze_task recommends server combinations with token estimation, while estimate_context_usage specifically estimates context usage for a given set. optimize_server_set and suggest_minimal_set both aim to reduce server count but differ in starting point (existing vs. from scratch). There is slight overlap but descriptions clarify purposes.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case (e.g., analyze_task, get_server_catalog). The naming is predictable and uniform, making it easy for an agent to understand the action and target.

Tool Count5/5

With 5 tools, the server is well-scoped for its purpose of optimizing MCP server context. The number feels neither too sparse nor excessive, covering key functionalities without unnecessary bloat.

Completeness4/5

The tool surface covers the core workflow: analyzing tasks, estimating context, getting catalog, and optimizing server sets. A minor gap is the lack of a tool to directly apply or save the optimization, but as an advisor, it is sufficiently complete.

Maintenance

ActivityInactive
ResponsivenessNo issues