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 (10 sats); HTTP 400 if invalid.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "segments_json": "<segments_json>"
    },
    "name": "plan_context_token_budget"
  }
}

Input 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

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.3/5.0
Behavior4/5

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

Annotations already cover readOnly/idempotent/non-destructive, but the description adds genuinely new operational facts: 32 KB payload cap, 60 RPM rate limit, demo-mode vs L402 (10 sats) auth paths, and HTTP 400 on invalid input. Only the redundant 'read-only edge call' phrase earns no credit; the rest is real disclosure beyond structured fields.

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?

Purpose is front-loaded in the first clause, and the sibling exclusion lands last. However, the second sentence is a dense run-on cramming payload size, rate limit, auth modes, and error code into one line, which slightly hurts scanability.

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

Completeness4/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-value explanation is correctly omitted. The description covers what is analyzed, cost dimension, resource limits, auth, and failure mode — enough for correct invocation, with only the segment JSON shape left entirely to the schema.

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 coverage is 100% with per-parameter descriptions and an enum, so the schema already carries parameter meaning. The description only notes that segments_json has 'enum defaults' and assumes knowledge of the segment shape, adding little beyond the schema.

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 specific operations (BPE token counting across segments, Lost-in-the-Middle attention-trough detection, multi-model USD/satoshi cost calculation) on a clearly identified resource (prompt segments). The final clause explicitly contrasts it with sibling prune_context_skeleton, so an agent can route without opening a 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?

Provides an explicit 'use when' list (auditing token budgets, reordering sections for primacy/recency, comparing API costs) and an explicit 'use X instead' exclusion for the compression case. Both the positive trigger and the negative boundary are stated.

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