# logpare > Semantic log compression for LLM context windows. Uses the Drain algorithm to collapse > repetitive log lines into templates with occurrence counts, reducing tokens by 60-90% > while preserving diagnostic information (severity, URLs, status codes, correlation IDs, > durations). ## Install ```bash npm install logpare ``` ## Minimal example ```typescript import { compress } from 'logpare'; const result = compress([ 'ERROR Connection to 192.168.1.100 failed', 'ERROR Connection to 192.168.1.101 failed', 'INFO Request processed in 45ms', ]); console.log(result.formatted); // === Log Compression Summary === // Input: 3 lines → 2 templates (33.3% reduction) // // Top templates by frequency: // 1. [2x] ERROR Connection to <*> failed // 2. [1x] INFO Request processed in <*> ``` ## Which interface - **CLI** — you have a file or a pipe and want compressed text now: `logpare app.log`, `cat /var/log/syslog | logpare`. No `compress` subcommand exists; pass options and paths directly. - **Library** — you are writing code that reads `result.templates` / `result.stats`, needs custom masking, or feeds lines in incrementally via `createDrain()`. Algorithm options are nested: `compress(logs, { drain: { depth: 5 } })`. `createDrain()` takes them flat. Compression is a diagnostic representation, not an archive — keep the original logs. ## Documentation - [Getting Started](https://logpare.com/docs.md): What logpare does, the problem it solves, and where to go next — start here. - [Installation](https://logpare.com/docs/installation.md): Install logpare globally, per-project, or run it with npx, and confirm the install works. - [Quick Start](https://logpare.com/docs/quick-start.md): Compress your first log file from the CLI and from TypeScript, and read the output formats. ## API reference - [compress()](https://logpare.com/docs/api/compress.md): Compress an array of log lines into semantic templates — the main entry point for most callers. - [compressText()](https://logpare.com/docs/api/compress-text.md): Compress a multiline string of log data — a thin wrapper over compress() that splits on newlines. - [createDrain()](https://logpare.com/docs/api/create-drain.md): Create a Drain instance for incremental or streaming log processing, when you need to feed lines in over time instead of all at once. - [Types Reference](https://logpare.com/docs/api/types.md): Every exported TypeScript interface, type alias, constant, and utility function, with its real shape. ## Guides - [Parameter Tuning Guide](https://logpare.com/docs/guides/parameter-tuning.md): Diagnose too many or too few templates and pick depth, simThreshold, maxChildren, and maxClusters for your log type. - [Custom Preprocessing](https://logpare.com/docs/guides/custom-preprocessing.md): Mask domain-specific IDs, retokenize non-whitespace log formats, and vary the similarity threshold by depth. - [MCP Integration](https://logpare.com/docs/guides/mcp-integration.md): Current status of the logpare MCP server, how to run it from source today, and the client configs it will use once published. ## Reference - [CLI Reference](https://logpare.com/docs/cli.md): Every flag the logpare CLI accepts, with real defaults, exit codes, and piping recipes. ## More - [Full documentation](https://logpare.com/llms-full.txt): Every page above concatenated, for when you want the whole reference in one fetch. - [Source repository](https://github.com/logpare/logpare): Issues, contributing guide, and the MCP server package. - [npm package](https://www.npmjs.com/package/logpare): Published releases and install instructions. ## MCP An MCP server lives in this repository at `packages/mcp`. It is **not published to npm**, so `npx @logpare/mcp` will fail; build it from source and point your client at `packages/mcp/dist/cli.js`. See the MCP integration page above.