TOMAPE
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.
TOMAPE
Token-optimized multi-agent orchestration exposed as an MCP server. TOMAPE owns session state, compacts context between agent hops, routes work to smaller models when safe, and reports estimated token savings.
Features
Session-owning orchestrator — clients send tasks, not full transcripts
Context compaction — structured handoff state between planner/worker/reviewer hops (typically 3–5× compression)
Dynamic routing — rule-based small/large model selection with escalation
Token metrics — per-hop breakdown and estimated baseline savings
Dual transport — stdio (Cursor/Claude Desktop) and HTTP (hosted teams)
API key auth — Bearer token authentication for HTTP mode
MCP resources — inspect handoff state and hop logs per session
Related MCP server: Headroom Mini
Quick Start
Full walkthrough: docs/SETUP.md
Prerequisites
Python 3.11+
uv (recommended)
Install
git clone https://github.com/sudharsanbabu83/TOMAPE.git
cd TOMAPE
uv sync --extra dev
cp .env.example .env
uv run tomape init-dbAdd your LLM API key to .env (see Model configuration).
Run locally (mock — no API key)
# Windows PowerShell
$env:TOMAPE_MOCK_LLM="1"; uv run tomape serve --transport stdio# macOS / Linux
TOMAPE_MOCK_LLM=1 uv run tomape serve --transport stdioRun locally (live LLM)
uv run tomape serve --transport stdioRun (HTTP — hosted)
uv run tomape serve --transport http --port 8080Health check: GET http://localhost:8080/health
Cursor MCP Setup
Copy an example config into your project:
Platform
Template
macOS / Linux
Windows
mkdir -p .cursor cp examples/cursor-mcp.json .cursor/mcp.json # adjust for your OSEdit
.cursor/mcp.json:Set
cwdto your TOMAPE repo root (required so config and.envload)Add
OPENAI_API_KEYorANTHROPIC_API_KEYinenvOn Windows, use the full path to
uv.exeifuvis not on PATH
Restart Cursor and confirm the
tomapeMCP server is connected.
Example config (macOS / Linux)
{
"mcpServers": {
"tomape": {
"command": "uv",
"args": ["run", "tomape", "serve", "--transport", "stdio"],
"cwd": "/path/to/TOMAPE",
"env": {
"OPENAI_API_KEY": "your-key",
"TOMAPE_MOCK_LLM": "0"
}
}
}
}MCP Tools
Tool | Description |
| Start a session ( |
| Follow-up without resending history |
| Poll running/completed/failed status |
| Final output + |
| Abort a session |
| Token metrics and savings |
MCP Resources
Resource | Description |
| Current compact handoff JSON |
| Truncated raw output per hop |
Example prompts (in Cursor)
Use TOMAPE submit_task: summarize the benefits of context compaction. Budget 5000 tokens. Profile economy.Use TOMAPE get_result for session sess_abc123Token report
get_result and get_token_report return a token_report with:
total_tokens— tokens used in the sessionbudget_tokens— session capestimated_baseline— estimated cost without compactionsavings_percent— reduction vs baselinehops[]— per-hop model, tokens, andcompaction_ratio
HTTP API
Authenticate with Authorization: Bearer <api-key>.
# List tools
curl -H "Authorization: Bearer dev-key-change-me" http://localhost:8080/tools
# Submit task
curl -X POST http://localhost:8080/tools/call \
-H "Authorization: Bearer dev-key-change-me" \
-H "Content-Type: application/json" \
-d '{"name":"submit_task","arguments":{"task":"Classify these items: apple, car, dog","profile":"economy","budget_tokens":5000}}'Docker
cd docker
TOMAPE_API_KEYS=dev-key-change-me OPENAI_API_KEY=sk-... docker compose up --buildConfiguration
Environment:
.env.examplePolicies:
config/default.yaml
Model configuration
Default models (OpenAI via LiteLLM):
Tier | Model |
small |
|
large |
|
Switch to Anthropic or any LiteLLM-supported provider by editing config/default.yaml and setting the matching API key in .env.
Profiles
Profile | Behavior |
| Small models, aggressive compaction, no escalation |
| Small default, escalate on failure |
| Large models, light compaction |
Compaction policies
Policy | Best for |
| General tasks |
| Coding, file edits, test output |
| Search, sources, key findings |
Development
uv run pytest
uv run ruff check tomape testsSet TOMAPE_MOCK_LLM=1 to run without API keys.
Architecture
Client → MCP (stdio/HTTP) → Orchestrator → Router → LLM
↓
Compaction → Session Store → MetricsInternal agents: Planner → Worker (per step) → Reviewer
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceMulti-model agent orchestration MCP server that enables plan-code-review-deliver pipelines with configurable providers and models.-
- AlicenseBqualityDmaintenanceLocal MCP server for token optimization, providing tools to compress code/JSON, optimize prompts, and manage placeholder-based content redaction and hydration to reduce LLM token usage.5ISC
- AlicenseNot gradedqualityBmaintenanceA context window optimizer and session rotator MCP server for agentic workflows that prevents LLMs from running out of context by compacting chat history and rotating sessions.2 npmMIT
- AlicenseNot gradedqualityCmaintenanceA local-first MCP server that reduces LLM token usage by intercepting, deduplicating, compressing, and optimizing MCP tool calls and responses.5 npmMIT