Command Palette

Search for a command to run...

UnylyUnyly
Browse all

Tikz

FreeNot checked

Compiles TikZ code into high-resolution PNG images, enabling AI assistants to render and preview LaTeX/TikZ diagrams during conversations.

GitHubEmbed

About

Compiles TikZ code into high-resolution PNG images, enabling AI assistants to render and preview LaTeX/TikZ diagrams during conversations.

README

A lightweight MCP (Model Context Protocol) server that compiles TikZ code into high-resolution PNG images. Lets AI assistants render and preview LaTeX/TikZ diagrams during conversations.

Features

  • Single tool: compile_tikz -- pass TikZ code, get a PNG image
  • Auto-wrapping: Raw TikZ commands are automatically wrapped in a standalone document
  • Custom preamble: Pass your own \usepackage / \usetikzlibrary commands
  • High resolution: Output at 1000 DPI by default, with transparent background
  • Graceful errors: LaTeX compilation errors are captured and returned as readable messages
  • Style guide: Built-in aesthetic rules injected into AI instructions for consistent, publication-quality output
  • Self-verification: AI is instructed to inspect its own output and fix issues before presenting to the user
  • Zero idle cost: Uses stdio transport -- no background process when not in use

Prerequisites

  • Python >= 3.10
  • LaTeX: pdflatex in PATH (e.g. via MacTeX or TeX Live)
  • Poppler: pdftoppm in PATH (install via brew install poppler), OR Ghostscript gs in PATH (ships with MacTeX)

Installation

pip install tikz-mcp

Or install from source:

git clone https://github.com/FlorianHuo/tikz-mcp.git
cd tikz-mcp
pip install .

Usage

As an MCP server (stdio)

Add to your MCP client config (e.g. Antigravity settings.json, Claude Desktop claude_desktop_config.json):

{
  "mcpServers": {
    "tikz-mcp": {
      "command": "tikz-mcp",
      "args": []
    }
  }
}

Or run with python:

{
  "mcpServers": {
    "tikz-mcp": {
      "command": "python3",
      "args": ["-m", "tikz_mcp.server"]
    }
  }
}

Tool: compile_tikz

Parameter Type Required Description
tikz_code string Yes TikZ code (raw commands or full document)
preamble string No Custom LaTeX preamble (replaces default)

Example -- raw TikZ code:

\begin{tikzpicture}
  \draw[thick, ->] (0,0) -- (3,0) node[right] {$x$};
  \draw[thick, ->] (0,0) -- (0,3) node[above] {$y$};
  \draw[blue, thick] (0,0) circle (2);
\end{tikzpicture}

The server auto-wraps this in a standalone document with common TikZ libraries loaded.

Example -- full document:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \fill[red] (0,0) rectangle (2,2);
\end{tikzpicture}
\end{document}

Output

Rendered PNGs are saved to $HOME/.tikz-mcp/output/ and the full path is returned.

Default Preamble

When raw TikZ code is provided (without \documentclass), the following preamble is used:

\usepackage{tikz}
\usepackage{amsmath,amssymb}
\usetikzlibrary{
    arrows.meta, calc, decorations.pathmorphing,
    decorations.markings, patterns, positioning,
    shapes.geometric, shapes.misc, fit, backgrounds,
    intersections, through, matrix, trees,
}

Override by passing a custom preamble parameter.

License

MIT

Changelog

v0.2.0

  • Embedded STYLE_GUIDE.md into server instructions with inline code patterns and anti-patterns
  • Added physical/mathematical accuracy rules (real hyperbolas, correct slopes)
  • Added TikZ pitfalls section (dimension overflow, hatched fill workarounds)
  • Added self-verification workflow: AI must inspect output and fix issues before presenting
  • Default standalone border changed from 5pt to 8pt

v0.1.0

  • Initial release
  • compile_tikz tool with auto-wrapping, custom preamble, 1000 DPI output
  • stdio transport for zero idle resource usage

from github.com/FlorianHuo/tikz-mcp

Installing Tikz

This server has no published package — it is built from source. Open the repository and follow its README.

▸ github.com/FlorianHuo/tikz-mcp

FAQ

Is Tikz MCP free?

Yes, Tikz MCP is free — one-click install via Unyly at no cost.

Does Tikz need an API key?

No, Tikz runs without API keys or environment variables.

Is Tikz hosted or self-hosted?

Self-hosted: the server runs locally on your machine via the install command above.

How do I install Tikz in Claude Desktop, Claude Code or Cursor?

Open Tikz on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.

Related MCPs

Compare Tikz with

Not sure what to pick?

Find your stack in 60 seconds

Author?

Embed badge for your README

Browse similar

All development MCPs