DistillDistill

MCP Tools Reference

Reference for the 3 Distill tools — auto_optimize, smart_file_read, code_execute

MCP Tools Reference

Distill provides 3 always-loaded tools for optimizing LLM token usage.

auto_optimize — Universal Compression

Auto-detects content type and applies the optimal compression strategy.

StrategyContent TypeSavings
buildCompiler errors (tsc, rustc, webpack)95%
logsServer/test/build logs80-90%
errorsRepeated error lines70-90%
diffGit diffs60-80%
stacktraceStack traces50-80%
code / semanticSource code (TF-IDF)40-60%
configJSON/YAML configs30-60%
autoAuto-detect best strategyvaries

Parameters:

  • content (required) — The content to compress
  • strategy — Explicit strategy or auto (default)
  • aggressive — Maximum compression mode
  • preservePatterns — Regex patterns to preserve
  • formatplain or markdown

smart_file_read — AST-Powered Reading

Read code with AST extraction — get functions, classes, signatures without loading the full file.

5 modes:

  • skeleton — Signatures only (depth 1-3)
  • extract — Specific element by type and name
  • search — Find elements by query
  • full — File structure overview
  • auto — Detect from params

7 languages: TypeScript, JavaScript, Python, Go, Rust, PHP, Swift

Parameters:

  • filePath (required) — Path to the file
  • mode — Read mode (auto default)
  • target — For extract mode: {type, name}
  • query — For search mode
  • depth — Skeleton depth (1-3)

code_execute — Sandboxed TypeScript SDK

Execute TypeScript in a secure sandbox. Replaces 5-10 tool calls with one.

ctx.* SDK:

ctx.files.read(path)         // Read a file
ctx.files.glob(pattern)      // Find files by pattern
ctx.files.exists(path)       // Check if file exists

ctx.code.parse(content, lang)                  // Parse to structure
ctx.code.extract(content, lang, {type, name})  // Extract element
ctx.code.skeleton(content, lang)               // Signatures only

ctx.compress.auto(content, hint?)    // Auto-detect and compress
ctx.compress.logs(logs)              // Log summarization
ctx.compress.diff(diff)              // Diff compression
ctx.compress.semantic(content, ratio?) // TF-IDF compression

ctx.git.diff(ref?)        // Get diff
ctx.git.log(limit?)       // Commit history
ctx.git.blame(file, line?) // Blame info

ctx.search.grep(pattern, glob?)  // Search file contents
ctx.search.symbols(query)        // Find code symbols

ctx.utils.countTokens(text)      // Count tokens
ctx.utils.detectType(content)    // Detect content type
ctx.utils.detectLanguage(path)   // Detect language from path

Parameters:

  • code (required) — TypeScript code to execute
  • timeout — Timeout in ms (1000-30000, default 5000)

Security: 7-layer sandbox, 128MB memory limit, blocks eval, require, import(), process.

On this page