MCP File Compaction
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., "@MCP File Compactionread_file src/lib.rs"
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.
MCP File Compaction
An MCP server that reduces Claude context window costs by automatically summarizing files to their public interfaces.
The Problem
When Claude works on large tasks across multiple files, the context window grows continuously. Each API request costs based on the full size of the context, not just new tokens. This leads to quadratic cost growth:
Implement
ptr.rs(2KB) → Context: 2KBImplement
raw_page.rsusingptr.rs(3KB) → Context: 5KBImplement
paged_pool.rsusing both (4KB) → Context: 9KB
After finishing a file, Claude doesn't need the full implementation—just the public interface (structs, functions, traits).
Related MCP server: mcp-injector
The Solution
This MCP server:
Tracks the "active" file — the one you're currently editing (full contents)
Auto-summarizes inactive files — when you switch files, the previous one is summarized to just its public API
Uses AST parsing — deterministic, fast, no LLM calls for summarization
Handles unsupported languages gracefully — returns full contents without tracking
Installation
From GitHub (recommended)
npx github:YOUR_USERNAME/mcp-file-compactionLocal development
git clone https://github.com/YOUR_USERNAME/mcp-file-compaction.git
cd mcp-file-compaction
npm install
npm run buildConfiguration
Add to your Claude Code MCP settings:
{
"mcpServers": {
"file-compaction": {
"command": "npx",
"args": ["github:YOUR_USERNAME/mcp-file-compaction"]
}
}
}Or for local development:
{
"mcpServers": {
"file-compaction": {
"command": "node",
"args": ["/path/to/mcp-file-compaction/dist/index.js"]
}
}
}Add to your CLAUDE.md:
## File Operations
Use the file-compaction MCP server for file operations:
- `read_file` instead of `Read` when you need full file contents
- `peek_file` when you only need to check interfaces
- `edit_file` instead of `Edit` for modifications
- `write_file` instead of `Write` for new files
- `file_status` to see tracked files and context savings
This reduces context window size by keeping only summaries of inactive files.Tools
read_file
Read a file and mark it as the active file. When you switch to a different file, the previous file is automatically summarized.
{ "path": "src/lib.rs" }peek_file
Get a summary of a file's public interface without changing the active file. Useful for checking APIs.
{ "path": "src/ptr.rs" }edit_file
Edit a file by replacing a specific string. The file becomes (or remains) the active file.
{
"path": "src/lib.rs",
"old_string": "fn old_name(",
"new_string": "fn new_name("
}write_file
Write content to a file, creating it if needed. The file becomes the active file.
{
"path": "src/new_module.rs",
"content": "//! New module\n\npub fn hello() {}\n"
}file_status
Show all tracked files with size comparison and savings.
Context Status
==============
Active: src/paged_pool.rs (full, 4.2 KB)
Cached Summaries:
src/ptr.rs 312 B (was 2.1 KB, saved 1.8 KB)
src/raw_page.rs 428 B (was 3.4 KB, saved 3.0 KB)
Total Context: 5.2 KB
Without Compaction: 11.5 KB
Savings: 6.3 KB (55%)forget_file
Remove a file from tracking entirely.
{ "path": "src/old_file.rs" }Supported Languages
Currently supported for summarization:
Rust (.rs) — extracts public structs, enums, traits, functions, type aliases, constants, and re-exports
Unsupported file types are read/edited normally without tracking—they won't interfere with compaction.
How Summaries Work
For a Rust file like:
//! Type-safe pointer wrappers.
use std::marker::PhantomData;
#[derive(Debug, Clone)]
pub struct Ptr<T> {
raw: *mut T,
_marker: PhantomData<T>,
}
impl<T> Ptr<T> {
pub fn new(raw: *mut T) -> Self {
Self { raw, _marker: PhantomData }
}
pub fn is_null(&self) -> bool {
self.raw.is_null()
}
// Private helper
fn internal_check(&self) -> bool {
!self.raw.is_null()
}
}The summary becomes:
// Purpose: Type-safe pointer wrappers.
#[derive(Debug, Clone)]
pub struct Ptr<T> { ... }
impl<T> Ptr<T> {
pub fn new(raw: *mut T) -> Self;
pub fn is_null(&self) -> bool;
}Private items, implementation details, and doc comments are condensed—only the public interface remains.
License
MIT
Available Tools
6 toolsedit_fileA
Edit a file by replacing a specific string. The file becomes (or remains) the active file.
The old_string must:
Match exactly, including whitespace and indentation
Appear exactly once in the file (for safety)
After editing, the file's cached summary is updated.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to edit | |
| old_string | Yes | The exact string to replace (must be unique in the file) | |
| new_string | Yes | The string to replace it with |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden and does well by disclosing: 1) mutation behavior (editing changes file content), 2) safety constraints (exact match, uniqueness requirement), 3) side effects (file becomes/remains active, cached summary updated). It doesn't mention error handling or permissions, keeping it from a perfect score.
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?
Four concise sentences with zero waste. First sentence states core purpose, second explains file state change, next two detail old_string constraints, final sentence describes caching update. Every sentence earns its place with essential information.
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 mutation tool with no annotations and no output schema, the description does well by explaining the edit operation, safety constraints, and side effects. It could be more complete by mentioning what happens on failure (e.g., if old_string isn't found) or the format of any return value, but covers the essential behavioral 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 description coverage is 100%, so the baseline is 3. The description adds some semantic context about old_string requirements (exact match including whitespace, must be unique), but doesn't provide additional meaning for path or new_string beyond what the schema already documents.
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 specific action ('Edit a file by replacing a specific string') and distinguishes it from siblings like write_file (which likely creates/writes entire files) and read_file/peek_file (which are read-only). It also mentions the file becomes/remains active, adding operational context.
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 usage for targeted string replacement rather than full-file writes (contrasting with write_file), but doesn't explicitly state when NOT to use it or name alternatives. The safety constraints (exact match, unique occurrence) provide some contextual guidance for when this tool is appropriate.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
file_statusB
Show the status of all tracked files including:
The currently active file (full contents in context)
Cached summaries with size comparison
Total context savings from compaction
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what information is shown (e.g., active file, cached summaries) but lacks details on behavioral traits such as whether this is a read-only operation, potential performance impacts, or how data is formatted. For a tool with zero annotation coverage, this is a significant gap in transparency.
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 highly concise and well-structured, using a bulleted list to clearly outline the components shown by the tool. Every sentence (or bullet point) earns its place by adding specific value, and it is front-loaded with the main purpose. There is no wasted verbiage or redundancy.
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 tool's complexity (moderate, as it involves tracking and status reporting), lack of annotations, and no output schema, the description provides some context but is incomplete. It lists what is shown but does not cover behavioral aspects or output format details. For a tool with no structured data support, this is minimally adequate but leaves gaps in understanding how the tool behaves or what the return values entail.
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?
The tool has 0 parameters, and the schema description coverage is 100%, so there is no need for parameter semantics in the description. The baseline for this scenario is 4, as the description appropriately does not discuss parameters, avoiding redundancy. It focuses on the tool's output aspects instead.
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 purpose: to show the status of all tracked files, listing specific components like the active file, cached summaries, and context savings. It uses the verb 'show' with the resource 'tracked files', making the purpose unambiguous. However, it doesn't explicitly differentiate itself from sibling tools like 'peek_file' or 'read_file', which might also involve file status or content viewing, so it falls short of a perfect score.
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 mention sibling tools like 'peek_file' or 'read_file', nor does it specify contexts or prerequisites for usage. This lack of comparative or contextual information leaves the agent without clear direction on tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
forget_fileB
Remove a file from tracking. Useful for cleanup or when you no longer need a file's interface in context.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to forget |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It mentions 'Remove a file from tracking,' implying a mutation, but doesn't disclose behavioral traits such as whether this is reversible, requires specific permissions, affects file content, or has side effects like rate limits. The description adds minimal context beyond the basic action.
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 appropriately sized and front-loaded, with two concise sentences that directly state the purpose and usage without waste. Every sentence earns its place by providing essential information efficiently.
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 tool's complexity (simple mutation with one parameter), no annotations, and no output schema, the description is minimally complete. It covers the basic action and context but lacks details on behavioral aspects like effects or prerequisites, leaving gaps for an agent to understand full implications.
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 100% for the single parameter 'path,' which is documented as 'Path to the file to forget.' The description adds no additional meaning beyond this, as it doesn't elaborate on path formats or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the schema handles parameter documentation adequately.
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 purpose with a specific verb ('Remove') and resource ('file from tracking'), and distinguishes it from siblings like edit_file or write_file by focusing on cleanup rather than content manipulation. However, it doesn't explicitly differentiate from file_status or peek_file in terms of tracking removal versus status checking.
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 implied usage guidance by mentioning 'Useful for cleanup or when you no longer need a file's interface in context,' which suggests when to use it. However, it lacks explicit alternatives (e.g., when not to use it vs. delete operations) or clear differentiation from sibling tools like file_status for tracking management.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
peek_fileA
Get a summary of a file's public interface without changing the active file. Useful for checking APIs of files you've already worked on.
Returns:
For the active file: full contents
For previously read files: cached summary (public structs, functions, traits, etc.)
For unsupported file types: full contents
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to peek at |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's read-only ('without changing the active file'), returns different content based on file status (active vs. cached vs. unsupported), and mentions caching. However, it lacks details on permissions, rate limits, or error handling, leaving some gaps.
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 front-loaded with the core purpose, followed by a bulleted list for returns that efficiently clarifies behavior. Every sentence adds value without redundancy, making it appropriately sized and well-structured.
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 tool's moderate complexity (single parameter, no output schema, no annotations), the description is mostly complete: it explains purpose, usage, and behavioral nuances. However, it could improve by detailing output structure or error cases, slightly reducing completeness.
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?
The schema description coverage is 100%, so the parameter 'path' is fully documented in the schema. The description doesn't add any meaning beyond what the schema provides (e.g., no format examples or constraints), resulting in a baseline score of 3.
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 purpose with specific verbs ('Get a summary', 'checking APIs') and distinguishes it from siblings like read_file by emphasizing it doesn't change the active file. It identifies the resource as 'file's public interface' and explains the scope of what's returned.
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 clear context for when to use it ('useful for checking APIs of files you've already worked on'), implying it's for inspection rather than editing. However, it doesn't explicitly state when not to use it or name alternatives like read_file for full content access, which prevents a perfect score.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_fileA
Read a file and mark it as the active file. When you switch to a different file, the previous file is automatically summarized to just its public interface, reducing context size.
Supported languages for summarization: .rs, .py, .ts, .tsx, .js, .jsx, .php, .cs, .gd
For unsupported file types, returns full contents without tracking (same as standard file read).
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to read (absolute or relative) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: it marks files as active, automatically summarizes previous files when switching (reducing context size), lists supported languages for summarization, and explains fallback behavior for unsupported types. It doesn't cover potential side effects like performance impact 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 efficiently structured: first sentence states core purpose, second explains the active file behavior, third lists supported languages, fourth covers unsupported types. Every sentence adds value with zero wasted words, and it's appropriately sized for the complexity.
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 annotations and no output schema, the description does a good job covering the tool's behavior, language support, and fallback handling. However, it doesn't explain what 'public interface' summarization entails or provide examples of the output format, leaving some ambiguity for the agent.
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 100% for the single 'path' parameter, so the schema already documents it adequately. The description adds no additional parameter semantics beyond what the schema provides, maintaining the baseline score of 3 for high schema coverage.
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 purpose: 'Read a file and mark it as the active file.' It specifies the verb ('read'), resource ('file'), and distinguishes from siblings by explaining the active file tracking and summarization behavior, unlike simpler read tools like peek_file.
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 clear context on when to use this tool: for reading files with active tracking and summarization for supported languages, and for unsupported types it behaves like a standard read. However, it doesn't explicitly state when NOT to use it or name alternatives like peek_file for non-tracking reads.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
write_fileA
Write content to a file, creating it if it doesn't exist. The file becomes the active file.
Creates parent directories if needed.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to write | |
| content | Yes | Content to write to the file |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it writes content, creates the file if missing, makes it active, and creates parent directories. However, it lacks details on permissions, error handling, or what 'active' means operationally, leaving gaps for a mutation tool.
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 appropriately sized with three concise sentences, each adding value: the core action, the active file effect, and directory creation. It is front-loaded with the primary purpose, and there is no wasted text or redundancy.
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 a mutation tool with no annotations and no output schema, the description is moderately complete. It covers the basic behavior and side effects (e.g., creating directories), but lacks details on return values, error cases, or interaction with sibling tools, which could be important for an agent.
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 100%, so the schema already documents both parameters ('path' and 'content') adequately. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints, meeting the baseline for high schema coverage.
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 specific action ('write content to a file') and resource ('file'), and distinguishes it from siblings like 'read_file' or 'edit_file' by emphasizing creation and making it active. The phrase 'creating it if it doesn't exist' adds specificity beyond just 'write'.
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 usage for writing or creating files, but provides no explicit guidance on when to use this tool versus alternatives like 'edit_file' or 'read_file'. It mentions the file becomes active, which hints at context, but lacks clear when/when-not instructions or named alternatives.
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.
6 tool updates
v0.1.0- First observed
edit_file - First observed
file_status - First observed
forget_file - First observed
peek_file - First observed
read_file - First observed
write_file
TDQS
Each tool has a clearly distinct purpose with no overlap: edit_file modifies content, file_status shows tracking info, forget_file removes tracking, peek_file summarizes without activation, read_file reads and activates, and write_file creates/writes and activates. The descriptions clearly differentiate their functions, preventing misselection.
All tool names follow a consistent verb_noun pattern (e.g., edit_file, read_file, write_file) with no deviations in style or casing. This uniformity makes the tool set predictable and easy to navigate for an agent.
With 6 tools, the server is well-scoped for file compaction and management, covering essential operations like reading, writing, editing, tracking, and summarizing files. Each tool serves a necessary function without redundancy or bloat.
The tool set provides strong coverage for file compaction workflows, including CRUD-like operations (read, write, edit, forget) and status/summary features. A minor gap is the lack of a tool for batch operations or handling multiple files at once, but agents can work around this by iterating through individual tools.
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
Persistent memory for Claude Code and Cursor. Stop re-explaining your project every session.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Path-scoped team memories, rules and skills for Claude Code, Cursor, Codex and other MCP clients.
Project memory, semantic code search, and grounded agent context.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides intelligent summarization capabilities through a clean, extensible architecture. Mainly built for solving AI agents issues on big repositories, where large files can eat up the context window.1837MIT
- FlicenseAqualityAmaintenancePersistent daemon that compresses codebases via AST body folding before indexing them for AI coding assistants like Claude Code and Cursor 57-89% token reduction with sub-millisecond queries, verified on Django, Spring, and Next.js.124-
- AlicenseNot gradedqualityBmaintenanceReduces token costs for AI coding agents by indexing code symbols and returning only relevant functions/classes for a given task.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to efficiently analyze codebases by extracting AST skeletons, reducing token usage while preserving type contracts and interfaces.221MIT
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/UBTCodeNinja/mcp-file-compaction'
If you have feedback or need assistance with the MCP directory API, please join our Discord server