Metadata-Version: 2.4
Name: langchain-micompress
Version: 0.1.0
Summary: LangChain tools for MiCompress: compress images, PDFs, video, audio, Office documents and archives
Author-email: MiCompress <support@micompress.com>
License: MIT
Project-URL: Homepage, https://micompress.com/mcp-server
Project-URL: Issues, https://github.com/micompress/micompress-mcp/issues
Keywords: langchain,tool,agent,compress,compression,image,pdf,micompress
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core<2,>=0.3
Requires-Dist: pydantic>=2
Dynamic: license-file

# langchain-micompress

LangChain tools for [MiCompress](https://micompress.com): let your agent compress
**images, PDFs, video, audio, Office documents, EPUB books and archives**.

```bash
pip install langchain-micompress
```

## Usage

```python
from langchain_micompress import MiCompressCompressFile

tool = MiCompressCompressFile()          # anonymous, or MiCompressCompressFile(api_key="mc_...")
print(tool.invoke({"path": "report.pdf", "preset": "extreme"}))
# Compressed report.pdf → report-min.pdf: 4.2MB → 610.3KB (86% smaller).
```

With an agent:

```python
from langchain_micompress import MiCompressToolkit

tools = MiCompressToolkit().get_tools()   # micompress_compress_file, micompress_list_formats
agent = create_agent(model, tools)        # any LangChain / LangGraph agent
```

| Tool | What it does |
| --- | --- |
| `micompress_compress_file` | Compress a local file and write the smaller copy (default: `<name>-min.<ext>`). Arguments: `path`, optional `output_path`, `preset` (`lossless`, `recommended`, `extreme`), `max_width` (images). |
| `micompress_list_formats` | List the supported extensions by category. |

## API key (optional)

Without a key the tools work anonymously within per-format size limits. For larger files
create a free key at [micompress.com/account](https://micompress.com/account) and set
`MICOMPRESS_API_KEY`, or pass `api_key=`.

## What is sent where

The file is uploaded to micompress.com over HTTPS to be compressed. Uploaded originals are
deleted within about 10 minutes and results within 24 hours —
[privacy policy](https://micompress.com/privacy). Files reachable by URL can also be
compressed with the hosted MCP server at `https://micompress.com/mcp`
([docs](https://micompress.com/mcp-server)).

## License

MIT
