Skip to main content
Glama

Diogenes Context Compression, Code Patching & Deterministic Solver MCP

BPE Token Budget, Attention Trough & Multi-Model Cost Planner

plan_context_token_budget
Read-onlyIdempotent

Counts subword BPE tokens across prompt segments, detects high-priority instructions trapped in the 35%–72% Lost-in-the-Middle attention trough, and calculates USD/satoshi costs across frontier LLMs. Use when auditing prompt token budgets, reordering prompt sections for primacy/recency attention, or comparing model API costs; for actively compressing and stripping low-salience lines from a single large file, use prune_context_skeleton instead. Read-only edge call (32 KB, 60 RPM): accepts 'segments_json' (with enum defaults), uses '?demo=true' or L402 (30 sats); HTTP 400 if invalid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
segments_jsonYesJSON string or array of prompt segments '[{"name":"sys","text":"...","priority":10}]' to analyze.
max_context_tokensNoTarget model context window limit in tokens; defaults to 128000 when omitted.
target_model_familyNoPrimary model family for token-Window calibration; defaults to 'gemini_3_1' when omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
within_budgetYesTrue when total_input_tokens_est fits inside available_input_budget.
total_input_tokens_estYesTotal BPE tokens summed across all prompt segments.
lost_in_the_middle_warningsYesWarnings for high-priority segments positioned in the 35%–72% attention trough.
multi_model_cost_comparisonYesEstimated USD and satoshi inference cost across 5 frontier models.
optimal_primacy_recency_orderYesRecommended segment ordering placing critical instructions at prompt boundaries.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare the safety profile (readOnlyHint, idempotentHint, destructiveHint=false), and the description adds substantial operational context on top: a 32 KB payload cap, a 60 RPM rate limit, the '?demo=true' or L402 (30 sats) access path, and HTTP 400 on invalid input. That is exactly the kind of constraint detail annotations cannot carry.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded and every clause carries information (capabilities, triggers, alternative, constraints, error code). It is a dense semicolon-chained run-on, however, so the when-to-use versus when-not split reads less cleanly than it could.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists so return values need no explanation, and annotations cover the safety profile. The description fills the remaining gaps — access modes, rate/size limits, failure behavior, and the sibling boundary — so an agent has everything needed to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters and their defaults, making 3 the baseline. The description only restates that segments_json is accepted 'with enum defaults', adding almost nothing beyond the schema text.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names three concrete operations (counting subword BPE tokens across segments, detecting instructions in the 35%–72% attention trough, computing USD/satoshi costs across frontier LLMs) with a clear verb+resource structure. It also explicitly distinguishes itself from the sibling prune_context_skeleton, so an agent can route without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use triggers ('auditing prompt token budgets, reordering prompt sections for primacy/recency attention, or comparing model API costs') and an explicit when-not with the named alternative ('for actively compressing and stripping low-salience lines from a single large file, use prune_context_skeleton instead'). No inference required.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources