Metadata-Version: 2.5
Name: ferritex-mcp
Version: 0.1.0
Summary: Model Context Protocol server exposing FerriTeX LaTeX-to-PDF compilation to AI agents.
Project-URL: Homepage, https://github.com/RauhanAhmed/FerriTeX
Project-URL: Repository, https://github.com/RauhanAhmed/FerriTeX
Project-URL: Issues, https://github.com/RauhanAhmed/FerriTeX/issues
Author-email: Rauhan Ahmed Siddiqui <hello@rauhanahmed.in>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,latex,mcp,pdf,typesetting
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Requires-Python: >=3.10
Requires-Dist: ferritex<0.2,>=0.1.0
Requires-Dist: mcp<3,>=1.2
Description-Content-Type: text/markdown

# ferritex-mcp

A [Model Context Protocol](https://modelcontextprotocol.io) server that exposes
[FerriTeX](https://github.com/RauhanAhmed/FerriTeX) to AI agents. An agent can turn LaTeX into a PDF
and validate LaTeX in a self-correction loop — without a TeX Live install and
without spawning subprocesses.

## Install

```bash
pip install ferritex-mcp
```

This pulls in `ferritex`, the in-memory LaTeX-to-PDF engine.

## Run

```bash
ferritex-mcp
```

Set `FERRITEX_MCP_OUTPUT_DIR` to a dedicated output directory. Relative
`output_path` values resolve under it; paths that resolve outside it return
`invalid_path`. If unset, paths are relative to the server's working directory
unless absolute. This is not a sandbox or an overwrite safeguard; use trusted
clients and restrict the server's filesystem permissions.

The server speaks MCP over stdio. Register it with your client, for example
Claude Desktop:

```json
{
  "mcpServers": {
    "ferritex": {
      "command": "ferritex-mcp"
    }
  }
}
```

## Tools

### `compile_latex_to_pdf`

Compiles a LaTeX document and writes the PDF to disk.

| Argument | Type | Description |
| --- | --- | --- |
| `latex` | string | A complete LaTeX document |
| `output_path` | string | Where to write the PDF |
| `engine` | string | `"fast"`, `"full"`, or `"auto"` (default) |
| `margin` | string? | Uniform margin override, e.g. `"1in"` |
| `font_size` | string? | Base font size override, e.g. `"11pt"` |

Returns:

```json
{
  "success": true,
  "output_path": "paper.pdf",
  "engine_used": "fast",
  "compile_time_ms": 6.2,
  "page_count": 2,
  "bytes": 18234,
  "warnings": []
}
```

On failure, `success` is `false` and `error` is one of `syntax`, `unsupported`,
`full_engine_missing`, `asset`, `compilation`, or `invalid_path`, with a human-readable message
and, for syntax errors, `line`, `column`, and `snippet`.

### `validate_latex`

Dry-run validation: no PDF is written. Returns structured diagnostics so an
agent can fix and retry.

```json
{
  "valid": false,
  "error": "syntax",
  "message": "unclosed brace `{` (line 3, column 45)",
  "line": 3,
  "column": 45,
  "snippet": "\\textbf{bold text"
}
```

## Why it matters

The fast engine lets agents validate and render supported documents without
starting a TeX executable on each revision. Validation checks fast-mode
compilation, not compatibility with every LaTeX package.

## License

MIT. See [LICENSE](LICENSE).
