Headroom Mini
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Headroom Minicompress this Python script to reduce tokens"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Headroom Mini
Headroom Mini הוא שרת MCP מקומי לניתוב וייעול טוקנים עבור פרומפטים ושליחת תוכן ל-LLM.
מה הפרויקט עושה
מיישם שרת MCP (
@modelcontextprotocol/sdk) עם כלים ל:דחיסת קוד (
compress_code)דחיסת JSON (
compress_json)אופטימיזציית פרומפטים (
optimize_prompt)הזרקת placeholder הפיכה (
redact_content)שחזור תוכן דרך placeholder (
hydrate)
משתמש בספרייה
gpt-tokenizerכדי להדפיס סטטיסטיקת טוקנים ברורה לכל פעולה.מנהל מזהי placeholder עם
HEADROOM_REDACTED_LOGS_ID_<NUM>ושומר תוכן לשחזור.התהליך מתבצע מקומית בזמן ריצה, ללא אחסון קבוע מחוץ לזיכרון הריצה.
Related MCP server: slimctx-token-optimizer
מבנה הפרויקט
src/– קוד המקורsrc/tools/– פונקציות עזרsrc/storage/– אחסון placeholder רוחבי לזמן ריצהtests/– טסטים יחידה
איך להתקין ולהריץ
npm install
npm startהפקודה npm start תבנה את הקוד לפני ההרצה בעזרת prestart.
לריצה מהירה בסביבת פיתוח (בלי תהליך בנייה נפרד):
npm run devלהרצת הטסטים:
npm testדוגמת שימוש
התקנה והרצה:
npm install
npm startהפעלת שרת MCP מקומי:
npm run devבדיקת יחידות:
npm testלהגשה: יש לכלול את כל הקבצים במקור ללא node_modules ובלי dist.
כלים בשרת MCP
compress_code– מסיר הערות, docstrings וקווים ריקים מקודcompress_json– בודק JSON וממזג אותו לשורה אחתoptimize_prompt– מוציא חותמות זמן ו-UUIDים ומעביר אותם לסוף הפרומפטredact_content– מחליף תוכן ארוך מעל 500 תווים ב-placeholderhydrate– מקבל placeholder או טקסט המכיל אותו ומחזיר את התוכן המקורי
דוגמת schema של כלי MCP
{
name: "compress_code",
description: "Compresses code by removing comments and whitespace",
inputSchema: {
type: "object",
properties: {
code: { type: "string" }
},
required: ["code"]
}
}זהו המבנה שבו סוכן AI יכול לזהות מתי להפעיל כלי דחיסה לפני שליחה ל-LLM.
תשובה לחלק 1.1
1. למה הזזת שדות דינמיים לסוף זה חשוב?
הזזת שדות דינמיים כמו חותמות זמן או UUID לסוף הפרומפט שומרת על החלק ה"קבוע" של הטקסט זהה בין בקשות שונות. זה מאפשר למודלים ולהיצעי cache של ספקים לזהות שהפרומפט הוא אותו פרומפט עם שינויים קטנים, וכך נמנע "cache miss". ההשפעה הכלכלית היא חיסכון משמעותי בעלויות שימוש ב-API, כי מודלים לא צריכים לנתח שוב ולקדד מחדש פרומפטים שבהם רק הנתונים הדינמיים השתנו.
2. כיצד לולאת פידבק עם placeholders עובדת?
במנגנון זה התוכן המלא נחתך כשגדול מדי, ובמקומו מוחדר מזהה מיוחד כגון:
[HEADROOM_REDACTED_LOGS_ID_1].
אם המודל צריך את התוכן המקורי בשיחה הבאה, הוא יכול לבקש אותו במפורש.
השרת יכול להזרים חזרה את התוכן דרך hydrate, ובכך לשמור על דחיסה ראשונית ועדיין לאפשר שחזור מלא של המידע במידת הצורך.
תשובה לחלק 1.2
תרשים זרימה של מחזור חיים
flowchart LR
Dev["מפתח/ת (Cursor IDE)"] --> Client["Cursor / MCP Client"]
Client --> Server["Headroom-Mini MCP Server"]
Server --> LLM["מודל יעד (Anthropic / Claude)"]
subgraph preprocessing ["Headroom-Mini Processing"]
TokenCount["Token Counting"]
CacheAnalysis["בדיקת cache / ניתוח סטטי"]
CompressCode["דחיסת קוד / JSON"]
PromptOptimize["אופטימיזציית פרומפט"]
Redact["הזרקת placeholders"]
Hydration["לולאת פידבק / Hydrate"]
end
Client --> TokenCount
TokenCount --> CacheAnalysis
CacheAnalysis --> CompressCode
CompressCode --> PromptOptimize
PromptOptimize --> Redact
Redact --> LLM
LLM --> Hydration
Hydration --> Serverהסבר זרימה
המפתח כותב קוד או פרומפט ב-Cursor.
Cursor שולח את הבקשה לשרת MCP המקומי.
Headroom-Mini סופר טוקנים, מנתח שדות דינמיים, דוחס קוד/JSON ויכול להחליף תוכן גדול ב-placeholders.
אם המודל מבקש מידע נוסף, המערכת מקבלת מזהה placeholder מהשיחה, והשרת מחזיר את התוכן המקורי באמצעות
hydrate.
תשובה לחלק 3
שימוש ביכולות AI פנימיות של Cursor
בפרויקט זה ניתן היה לנצל את יכולות ה-AI של Cursor כדי להבין את מבנה המלל והכלים של Headroom, וליצור את ה-schema של הכלים בצורה מדויקת. ה־README כולל הסברים על כל כלי והטמעה של שרת MCP, מה שמ יוצר ממשק ברור עבור סוכן.
איך סוכן AI משתמש ב-schema של כלי MCP?
כאשר מגדירים כלי MCP עם name, description ו־inputSchema, סוכן AI יכול להבין באיזה תנאים כדאי להפעיל כל כלי.
למשל, אם הטקסט מכיל JSON גדול, הסוכן יכול להפעיל compress_json לפני שליחה.
זה יאפשר לו לבחור האם לנסות דחיסה או hydration בהתאם לבקשה ולתוכן.
איך Cursor יכול להפעיל את הכלים
בממשק של Cursor, סוכן ה-AI יכול לבחור כלי MCP מתוך הרשימה שהוגדרה לו ולהפעילו בזמן כתיבת בקשה או שליחת פרומפט.
לדוגמה, אם המשתמש כותב בקשה עם קוד ארוך, הסוכן יכול לבחור compress_code; אם יש JSON גדול, הוא יכול לבחור compress_json; ואם יש צורך בשחזור תוכן, הוא יכול להשתמש ב-hydrate.
זה הופך את התהליך לאוטומטי, שקוף, וממוקד בהקטנת עלויות התקשורת עם המודל.
מדידת טוקנים
דוגמה להדפסה שנמצאת בזמן הריצה:
Original tokens: 2450
Optimized tokens: 1320
Saved tokens: 1130 (46%)המדידה הזאת מתבצעת באמצעות gpt-tokenizer ומאפשרת לראות את ההשפעה המעשית של הדחיסה.
טסטים
הפרויקט כולל טסטים למקרים קריטיים:
בדיקת הסרת comments מקוד
בדיקת minify של JSON
בדיקת replacement של placeholder ארוך
בדיקת אופטימיזציית prompt עם timestamps ו-UUID
ניתן להריץ את כל הטסטים עם:
npm testהערות נוספות
אין
node_modulesבתיעוד, וניתן להריץ את הפרויקט אחריnpm installבתוך פחות מ-3 דקות.יש טסטים שמכסים את הלוגיקה המרכזית; ניתן להריץ אותם באמצעות
npm test.
Available Tools
5 toolscompress_codeB
Semantic code compression (removes comments + whitespace)
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Without annotations, the description must disclose behavior. It states it removes comments and whitespace, which is transparent, but doesn't mention if it's reversible or language-specific.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One sentence, front-loaded with the core action and details. No unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with one parameter and no output schema, the description covers the main action but lacks details on input constraints or results. Adequate but not comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description should compensate. The description does not add any information about the 'code' parameter beyond its name, such as format, language support, or size limits.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'compress' and the resource 'code', and specifies it removes comments and whitespace. It distinguishes from siblings like compress_json by focusing on code, though not explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus alternatives such as compress_json or hydrate. No context about prerequisites or limitations.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
compress_jsonB
Minify JSON safely without breaking structure
| Name | Required | Description | Default |
|---|---|---|---|
| json | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must fully disclose behavior. It only mentions safety and structure preservation, but lacks details on what exactly is minified (whitespace? comments?), edge cases, or error handling.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single front-loaded sentence with no wasted words. However, it could be slightly more informative without losing conciseness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple single-string tool, the description gives the purpose but lacks constraints or usage context. Without annotations or output schema, the agent has insufficient guidance to invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0% for the single parameter. The description does not mention the 'json' parameter at all, failing to add meaning beyond the bare schema type definition.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb 'minify' and resource 'JSON', and the phrase 'safely without breaking structure' adds clarity. It clearly distinguishes from siblings like compress_code, which targets code, and optimize_prompt, which targets prompts.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies use for compressing JSON while preserving validity, but does not explicitly state when to use this tool versus alternatives, nor does it provide when-not or exclusion criteria.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
hydrateC
Restores content from HEADROOM_REDACTED placeholders
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided. The description does not disclose side effects, authentication needs, rate limits, or whether the tool modifies state. It only states the function without behavioral context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise (one sentence). While not verbose, it could include more essential information without being lengthy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, no annotations, and a single parameter, the description is insufficient. It does not explain return values, limitations, or usage context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0% and the description does not explain the 'text' parameter beyond its type. No details on format, expected input, or purpose.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action (restores) and the resource (content from placeholders). It distinguishes from sibling tools which are about compression and redaction, implying this is a reversal of redaction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool or when not to. Lacks mention of prerequisites like prior redaction or alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
optimize_promptB
Moves dynamic fields (timestamps / UUIDs) to end for better cache performance
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must fully explain behavior. It states the core transformation but omits critical details: whether the prompt is expected to be a JSON string or plain text, how dynamic fields are identified (e.g., regex), what happens if no dynamic fields exist, and whether the return value is a new string or modified in-place. This lack of specificity limits agent understanding.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that immediately states the action and purpose. Every word contributes meaning, and the structure is front-loaded with the verb 'moves'. No redundant or extraneous content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simplicity of the tool (one parameter, no output schema, no annotations), the description lacks essential context for reliable agent invocation. It does not specify expected input format, return value, edge case handling, or performance implications. The agent cannot predict tool behavior beyond the stated transformation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must supplement the parameter definition. However, the description does not clarify what format the 'prompt' parameter should take (e.g., JSON string, plain text) or how dynamic fields are defined within it. The agent has only the type 'string' and no additional semantic clues.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's action ('Moves dynamic fields... to end') and specifies the resource ('prompt'). It distinguishes itself from sibling tools like compress_code, compress_json, hydrate, and redact_content by focusing on reordering for cache performance rather than compression or content alteration.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It does not specify prerequisites, typical use cases, or conditions under which the tool is effective. The agent must infer usage from the name and brief action statement.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
redact_contentB
Redacts oversized code / logs and replaces them with a reversible placeholder
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses the core behavior (redaction and reversible placeholder) but lacks details on thresholds for 'oversized', the nature of reversibility, or side effects. With no annotations, the description carries the burden but is somewhat sparse.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single focused sentence with no extraneous words, front-loading the key action and result. It is efficient and to the point.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite the tool's simplicity, the description omits important context such as what 'oversized' means, how the placeholder is generated, and whether the operation is reversible automatically. Without annotations or output schema, the agent may miss crucial operational details.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, yet the description merely implies the 'content' parameter is the code/logs to redact. It does not explain format, size constraints, or expected input, providing minimal compensation for the missing schema details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: redacting oversized code/logs and replacing them with a reversible placeholder. It distinguishes itself from siblings like compress_code and optimize_prompt by focusing on redaction with reversibility.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus siblings. It does not specify conditions for use, prerequisites, or alternatives, leaving the agent to infer from the name alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.0- First observed
compress_code - First observed
compress_json - First observed
hydrate - First observed
optimize_prompt - First observed
redact_content
TDQS
Each tool targets a distinct operation: compression of code vs JSON, redaction, hydration, and prompt optimization. There is no functional overlap.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., compress_code, redact_content), making them predictable for an agent.
With 5 tools, the server is well-scoped for content manipulation tasks. Each tool serves a clear purpose without unnecessary redundancy.
The set covers compression, redaction, hydration, and prompt optimization, but lacks a decompress tool for JSON minification and potentially other common formats, leaving a minor gap.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Related MCP Servers
- AlicenseAqualityAmaintenanceLocal MCP server that uses a local Ollama model to rewrite rough prompt drafts into structured, optimized prompts for paid APIs, saving tokens and improving output quality.525MIT
- AlicenseAqualityAmaintenanceProvides reversible context compression for AI agents, reducing token usage while preserving the ability to retrieve original content, and serves as an MCP server for integration with tools like GitHub Copilot and Claude Code.31Apache 2.0
- AlicenseNot gradedqualityCmaintenanceA local, zero-cloud MCP server for token and text compression. It provides tools to compress, auto-compress, measure, and decompress text using offline rules, lossless gzip packing, or a local Ollama semantic model.1MIT
- AlicenseNot gradedqualityCmaintenanceA local-first MCP server that reduces LLM token usage by intercepting, deduplicating, compressing, and optimizing MCP tool calls and responses.6MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/lea-blum/headroom-mini-token-optimizer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server