tksq
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.
tksq
Universal LLM token compression MCP server. Squeeze your tokens.
tksq reduces token consumption when working with LLMs by compressing text through a multi-stage pipeline. It removes filler phrases, applies concise substitutions, eliminates redundancies, and normalizes whitespace — all while preserving code blocks, URLs, and semantic meaning.
Works as an MCP server with any compatible client: Claude Code, Cursor, VS Code, and more.
Features
4-stage compression pipeline: Cleanup, Semantic, Structural, Shorthand
3 compression levels: light, medium, aggressive
Multilingual: English and Russian language packs with full pipeline support
4 domain dictionaries: general, programming, legal, academic
Learning buffer: Discovers repeating patterns, suggests new substitutions
Agent orchestration: Ready-made tools for multi-agent token optimization
9 MCP tools for compression, analysis, configuration, and monitoring
Related MCP server: TokenSkein
Quick Start
With Claude Code
Add to your MCP config (.mcp.json):
{
"mcpServers": {
"tksq": {
"command": "npx",
"args": ["-y", "tksq"]
}
}
}With Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"tksq": {
"command": "npx",
"args": ["-y", "tksq"]
}
}
}How It Works
tksq processes text through up to 4 compression stages:
Input: 120 tokens
-> [Cleanup]: 115 tokens (-4.2%) # whitespace, fillers, redundancy
-> [Semantic]: 85 tokens (-26.1%) # phrase substitution, abbreviations
-> [Structural]: 82 tokens (-3.5%) # dedup, pattern collapse
-> [Shorthand]: 75 tokens (-8.5%) # telegraphic, deverbal nouns
Total: 120 -> 75 tokens (37.5% saved)What gets compressed
Filler phrases: "I would like to", "it is worth noting that", "basically" -> removed
Verbose phrases: "in order to" -> "to", "due to the fact that" -> "because"
Redundancies: "completely unique" -> "unique", "return back" -> "return"
Whitespace: multiple blank lines, trailing spaces, extra spaces
Russian: fillers, bureaucratic constructions, deverbal nouns, pronoun elision
What stays untouched
Code blocks (fenced and inline)
URLs
Long quoted strings
Custom patterns you specify
Tools
Core Compression
tksq_compress
Compress text with full per-stage statistics.
Parameters:
text (required) The text to compress
level (optional) "light" | "medium" | "aggressive"
domain (optional) "general" | "programming" | "legal" | "academic"
language (optional) "auto" | "en" | "ru"
tokenizer (optional) "cl100k_base" | "o200k_base" | "approximate"
preserve_patterns (optional) Additional regex patterns to preservetksq_count
Count tokens without compressing.
tksq_diff
Show word-level diff between original and compressed text.
tksq_benchmark
Benchmark compression across all levels side by side.
Configuration
tksq_configure
Read or update persistent configuration. Shows current settings, custom substitutions, promoted patterns, and learning config.
Learning
tksq_learn
Manage the learning buffer — patterns discovered from your usage.
Actions:
list Show candidate patterns with frequency counts
promote Activate a candidate as a compression substitution
reject Remove a false positive from candidates
add Manually add a pattern (phrase -> replacement)
reset Clear all learned data
stats Show compression statisticstksq_dashboard
Comprehensive overview: all-time stats, configuration, learning buffer state, dictionary sizes.
Agent Orchestration
tksq_agent_prompt
Get a ready-made system prompt snippet for multi-agent token optimization. Include in agent system prompts to enable pipeline-wide compression.
Parameters:
role (required) "child" | "parent"
style (optional) "default" | "aggressive"tksq_pack
Compress agent output for return to parent agent. Optimized for pipelines: preserves code blocks, file paths, line numbers. Returns compressed text with minimal metadata footer.
Parameters:
text (required) Agent output to compress
level (optional) "medium" | "aggressive"
language (optional) "auto" | "en" | "ru"Compression Levels
Level | Stages | Expected Savings |
light | Cleanup | 5-15% |
medium | Cleanup + Semantic | 20-40% |
aggressive | All 4 stages | 30-50%+ |
Multilingual Support
tksq auto-detects language (English/Russian) and applies the appropriate language pack.
Russian includes:
52 filler phrases, 99 substitutions, 49 redundancies
Pronoun elision, patronymic compression, comparative expansion
Deverbal noun compression (48 patterns across 10 verb families)
Bureaucratic phrase simplification
Domain Dictionaries
general (default): Prose-focused filler removal and substitutions
programming: Code abbreviations ("function" -> "fn", "configuration" -> "config")
legal: Legal-specific terminology and substitutions
academic: Academic writing patterns and abbreviations
Learning Buffer
tksq observes your compression patterns and discovers repeating phrases. When a phrase appears frequently enough, it suggests a shorthand substitution.
tksq_compress("...text...") -> tracks repeating n-grams
tksq_learn(action: "list") -> shows candidates with counts
tksq_learn(action: "promote", phrase: "machine learning", replacement: "ML")Promoted patterns are automatically applied in future compressions.
Data persists at:
Windows:
%APPDATA%\tksq\learned.jsonLinux/Mac:
~/.config/tksq/learned.json
Multi-Agent Orchestration
In multi-agent pipelines (Claude Code Task tool, etc.), tksq reduces token costs across the agent tree:
Parent agent includes
tksq_agent_prompt(role: "parent")in its contextChild agents get
tksq_agent_prompt(role: "child")in their system promptsBefore returning results, child agents call
tksq_packon their outputParent reads compressed results directly (LLMs handle compressed text well)
Typical savings: 20-40% reduction on natural-language analysis text per agent.
Configuration
Config file location:
Windows:
%APPDATA%\tksq\config.jsonLinux/Mac:
~/.config/tksq/config.json
{
"level": "medium",
"tokenizer": "cl100k_base",
"domain": "general",
"language": "auto",
"preservePatterns": [],
"customSubstitutions": {},
"learning": {
"enabled": true,
"minFrequency": 5,
"autoPromote": false,
"maxCandidates": 100
}
}Development
git clone https://github.com/Nexonium/tksq.git
cd tksq
npm install
npm run build
npm testProject Structure
src/
index.ts # Entry point (stdio MCP transport)
server.ts # MCP server, 9 tool registrations
pipeline/
Pipeline.ts # Stage orchestrator
stages/
CleanupStage.ts # Whitespace, fillers, redundancy
SemanticStage.ts # Substitutions, abbreviations
StructuralStage.ts # Dedup, pattern collapse
ShorthandStage.ts # Telegraphic, deverbal nouns
preserver/
PatternPreserver.ts # Protect code blocks, URLs
tokenizer/
TokenCounter.ts # tiktoken + approximate counter
dictionaries/
languages/
en.ts # English language pack
ru.ts # Russian language pack
types.ts # LanguagePack, ShorthandConfig
registry.ts # Language registry
domains/
general.ts, programming.ts, legal.ts, academic.ts
DictionaryLoader.ts # Dictionary loading and merging
language/
LanguageDetector.ts # Auto language detection
WordBoundary.ts # Unicode-aware word boundaries
learning/
types.ts # CandidatePattern, LearnedData, LearningConfig
PhraseStore.ts # JSON persistence for learned patterns
PhraseTracker.ts # Frequency analysis, replacement suggestion
config/
ConfigManager.ts # Persistent user config
defaults.ts # Default values
diff/
TextDiffer.ts # Word-level diffTool 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
Compress prose for LLM context windows. Per-call USDC billing, signed receipt.
Free no-LLM token savers: URL→Markdown, outline, JSON trim, log compress, token count; x402 extras
Compress coding-agent context ~64%. Hosted Neural Keep MCP for Cursor/Claude/Codex.
Token counting, RAG chunking, truncation, HTML to Markdown and JSON repair
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 gradedqualityDmaintenanceProvides compression, retrieval, and statistics for local context-economy when interacting with GPT/Codex, enabling efficient token usage and exact recovery of compacted content.3Apache 2.0
- FlicenseNot gradedqualityBmaintenanceShrinks logs, JSON, docs and web pages before your AI reads them: offline, deterministic, no API key. Folds repetitive log lines (12,037 to 127 tokens on a 400-line log) while code, URLs and quoted strings come back byte-for-byte. Also fetches URLs as clean text, counts tokens exactly, and has optional local Ollama tools for image and text compression.73 PyPI25-
- FlicenseNot gradedqualityNot gradedmaintenanceEnables MCP-compatible clients and autonomous agents to dynamically compress long-horizon context by pruning verbose tool outputs, HTML boilerplate, and semantic redundancy by 40-70%. It reduces token burn and latency through deterministic, zero-dependency processing.-