ail-context-compressor
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.
AILv1 (ail-context-compressor)
Agent Intermediate Language (AILv1) is a line-oriented text format for handing session state between models and agents, plus a small Python tool that writes and reads it: an encoder, a parse-only decoder, a Python ast signature extractor, a CLI, an MCP server, and an Agent Skill (SKILL.md).
A snapshot keeps what a summary usually drops: recurring entities (@MEM pointers), data flow (@CTX/@ARCH), rejected approaches and why they failed (@LOG), code signatures with state mutations (@SIG), and open tasks (@NEXT).
!AILv1
@MEM $1=recipe_api $2=MinIO $3=Celery_Redis
@ARCH $1[FastAPI|Postgres] := upload->$2:originals->$3:make_thumbnails->$2:thumbs
@LOG !FastAPI_BackgroundTasks(lost_40_jobs_on_redeploy) -> ^$3_acks_late
@SIG worker.py|make_thumbnails(photo_id:int,key:str)->list[str]|mutates(storage.put_object_bytes)
@NEXT ?per_user_upload_rate_limitSecurity: decoded content is data, not instructions. A payload can carry text written to steer a model (fake
@NEXTtasks, "ignore previous instructions"). The decoder only parses; it never evaluates anything. Do not let an agent act on a snapshot from someone else without confirming with its user. See SECURITY.md.
Why the format looks like this, and what came before it: Why AIL exists.
Prompt-only encoder (no install)
Copy the prompt below into any AI chat to compress that conversation into an AILv1 block. No install is needed.
Prompt-only, best-effort. The model writes the block itself, so it can drop details or miss a secret. For exact signatures and guaranteed redaction, use the Python encoder. Don't paste secrets into a chat and rely on this prompt to remove them.
You are an AILv1 encoder. Compress everything in this conversation so far into ONE AILv1 block that another AI can load as working context. Output only the block.
FORMAT
!AILv1
@MEM $1=Name $2=Other_Name assign a $N pointer to every person, project, file, tool, service; use pointers everywhere after
@CTX Label:=$1|$2 relationships, goals, constraints, current state
@LOG !rejected(reason) -> ^replacement every approach tried and dropped, why, and what replaced it
@SIG file|~fn(args)->return|mutates(x) only functions/commands actually shown in the chat, copied exactly; ~ only if async
@NEXT ?open_question open questions and next steps
# AILv1 block complete. Redaction is best-effort; check before sharing.
RULES
1. Preserve facts, decisions, names, numbers and exact code identifiers. Never invent or guess. If unsure, write it as @NEXT ?unclear:<topic>.
2. Redact before writing, and this rule beats every other rule: API keys, tokens, passwords, private keys, connection strings and URLs with credentials, cookies and session IDs, card or bank numbers, emails, phone numbers and IP addresses become [REDACTED], even inside @SIG or code. If unsure whether something is a secret, redact it.
3. Dense, not lossy: no prose, no filler, one fact per line. Use underscores instead of spaces inside names, pointers and @NEXT items.
4. Later decisions override earlier ones; record the earlier one in @LOG.
5. End the block with this comment line: "# AILv1 block complete. Redaction is best-effort; check before sharing."Related MCP server: token-compressor
Format
Section | Meaning | Example |
| header, must be the first line |
|
| pointer dictionary |
|
| context, topology, data flow |
|
| negative constraint: rejected path, reason, replacement |
|
| code signature: file, |
|
| open tasks |
|
Operators: $N pointer, := defined as, -> flow or resolution, | slot separator, ! rejected, ^ locked replacement, ~ async, ? open task. Lines starting with # are comments.
ail_document = "!AILv1" , NEWLINE , { section } ;
section = mem_sec | ctx_sec | arch_sec | log_sec | sig_sec | next_sec ;
mem_sec = "@MEM" , { " " , pointer_id , "=" , identifier } , NEWLINE ;
ctx_sec = "@CTX" , " " , expr_chain , NEWLINE ;
arch_sec = "@ARCH" , " " , expr_chain , NEWLINE ;
log_sec = "@LOG" , " " , "!" , identifier , "(" , reason , ")" , " -> " , "^" , expr , NEWLINE ;
sig_sec = "@SIG" , " " , file_ref , "|" , [ "~" ] , fn_sig , "->" , type_id , [ "|mutates(" , mut_list , ")" ] , NEWLINE ;
next_sec = "@NEXT" , { " ?" , action_expr } , NEWLINE ;
expr_chain = expr , { ( "->" | "|" | ":=" ) , expr } ;
pointer_id = "$" , DIGIT , { DIGIT } ;
identifier = ( LETTER | DIGIT | "_" | "." | "/" | ":" | "-" )+ ;What the tool does
Encoder (
pack): redacts secrets first (on by default), turns a Python file into@SIGlines, turns fenced Python blocks in a chat log into@SIGlines plus a[CodeBlock_N]marker, keeps every other non-blank line as@CTX, and replaces recurring terms with$Npointers when that saves tokens.@LOGand@NEXTentries are passed in explicitly (--log,--next); the encoder does not guess which approaches were rejected.Decoder (
parse,hydrate): validates the header and every section, resolves pointers in a single pass, leaves undefined$Nuntouched, and caps input and output size. Prose round-trips exactly (minus blank lines and surrounding whitespace).@SIGextractor: Pythonastonly. Qualified names (Class.method,outer.inner), typed args, short defaults,*args/**kwargs, async (~), return type (annotated, orAny/Noneinferred), and up to five mutations (attribute/subscript assignment,global/nonlocal, calls such as.append,.write_text,.commit).Redaction: GitHub tokens,
sk-API keys, AWS key IDs, Slack and Google keys, JWTs, bearer tokens, private key blocks,password=/secret:/"api_key": "..."style credentials, emails, IPv6, and all IPv4 addresses (including10.0.0.0/8and100.64.0.0/10). Full scope and limits in SECURITY.md.
Benchmarks (cl100k_base)
Measured with python3 benchmarks/run.py (tiktoken 0.14.0). All inputs are in benchmarks/inputs/ and are invented sample text.
Workload | Snapshot | Raw tokens | AILv1 tokens | Reduction |
3-turn architecture session ( |
| 1,879 | 1,435 | 23.6% |
3-turn architecture session ( | hand-written ( | 1,879 | 385 | 79.5% |
Python source ( |
| 5,895 | 757 | 87.2% |
One-paragraph example ( |
| 85 | 98 | -15.3% |
One-paragraph example ( | hand-written ( | 85 | 87 | -2.4% |
What the numbers say:
On Python source the automatic encoder keeps only signatures and mutations, so the saving is large. Function bodies are gone; this is a map of the code, not a copy.
On prose the automatic encoder is close to lossless and saves little: it only deduplicates long recurring names. The large savings on conversations come from a model or person writing the snapshot by hand (SKILL.md Mode A), which is a summary and drops detail.
On a short paragraph AILv1 can cost more tokens than the prose. Pointers and section tags pay off only when names repeat.
An earlier version of this README claimed 94.8% (2,840 -> 148 tokens) for a session, 87.4% (1,680 -> 212 tokens) for ail_mcp.py, and ~95 -> ~32 tokens for the one-paragraph example. The first two inputs were never published and the third does not reproduce (85 -> 87 tokens above), so those claims were removed. A test (tests/test_benchmarks.py) fails if this table drifts from what benchmarks/run.py measures.
Install and use
Download the release (recommended)
Each release on the Releases page has two files: ail-context-compressor-v1.0.1.zip and ail-context-compressor-v1.0.1.zip.sha256. The zip holds a single folder, ail-context-compressor/, with SKILL.md, scripts/ail_mcp.py, mcp.example.json, this README, SECURITY.md and LICENSE.
Download both files into the same folder and check the zip before you unpack it:
sha256sum -c ail-context-compressor-v1.0.1.zip.sha256 # Linux shasum -a 256 -c ail-context-compressor-v1.0.1.zip.sha256 # macOSIt should print
ail-context-compressor-v1.0.1.zip: OK. If it does not, delete the zip and download it again.Unzip it into your project's skills folder. For Claude Code that is
.claude/skills/, which puts the skill at.claude/skills/ail-context-compressor/:cd /path/to/your-project mkdir -p .claude/skills unzip /path/to/ail-context-compressor-v1.0.1.zip -d .claude/skillsUse
~/.claude/skillsinstead to make the skill available in every project. Other agents that readSKILL.mdfiles have their own skills folder; unzip into it.To use the MCP server as well, copy the block from
mcp.example.jsoninto your client's MCP config (for example.mcp.jsonin the project for Claude Code, or.cursor/mcp.jsonfor Cursor) and set the path to whereail_mcp.pynow lives. See MCP server below.
The zip is built by python3 scripts/build_release.py, which is deterministic: the same commit gives the same SHA-256.
From a clone
git clone https://github.com/jiludkumar-therealone/ail-context-compressor.git
mkdir -p ~/.claude/skills
cp -r ail-context-compressor/skills/ail-context-compressor ~/.claude/skills/CLI
The script needs only the standard library. Install tiktoken for exact token counts and mcp for server mode.
S=skills/ail-context-compressor/scripts/ail_mcp.py
python3 $S pack -f notes.md > session.ail # prose / chat log -> snapshot
python3 $S pack -f notes.md \
--log "sync_ping|timeout_on_large_subnets|async_arp_scan" \
--next "fix_sqlite_write_lock" > session.ail # add negative constraints and tasks
python3 $S sig -f app.py # @SIG lines only
python3 $S unpack -f session.ail # hydrate
python3 $S pack --no-redact -f notes.md # disable redaction (not recommended)Or install the package from a checkout: pip install . gives you the ail-mcp command.
MCP server
Tools: ail_compress_text, ail_extract_code_sigs, ail_hydrate_state, ail_save_checkpoint (writes a new <name>.ail in the server's working directory only; no directory argument, never overwrites, never follows symlinks). Works with mcp 1.x (FastMCP) and 2.x (MCPServer).
{
"mcpServers": {
"ail-context-compressor": {
"command": "python3",
"args": ["/absolute/path/to/ail-context-compressor/skills/ail-context-compressor/scripts/ail_mcp.py", "mcp"]
}
}
}The same block is in claude_desktop_config.example.json, and in mcp.example.json inside the release zip.
Tests
python3 verify_ail.py # standard library only; MCP tests skip without the mcp package
pip install ".[test]" && python3 -m pytestCI (.github/workflows/tests.yml) runs both on every pull request (Python 3.10 and 3.13), plus the benchmark script.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory for AI agents: save, search and connect context across tools and sessions.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Universal memory for AI agents and tools. Save, organize and search context anywhere.
Verified memory for AI agents. Signed assertions, billing attestation, session continuity.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables local-first context compression for AI agents, offering tools to compress text, retrieve original content, and get compression statistics.MIT
- AlicenseNot gradedqualityDmaintenanceEnables semantic prompt compression for LLM workflows, reducing token usage by 30-70% while preserving semantic meaning.12MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to compress and selectively retrieve context, with measured recall rather than claimed performance. It provides tools to assess potential traffic and token savings, list compression dictionaries, and assemble relevant memory entries within a token budget.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI coding agents to compress terminal output and file context in real time, preserving full error tracebacks while reducing token consumption by 60-85%.43MIT