Skip to main content
Glama

rayomd-mcp

Markdown to PDF for AI agents, over MCP, in about half a millisecond a call. No browser. No LaTeX. No Pandoc. No Chrome to download.

Quick start · Tools · Security · Performance · RayoMD

NOTE

Not on npm yet. Until rayomd-mcp's first npm release, run it from this repository (Build from source); the npx commands below work from then on. It needs RayoMD 5.3.0 or newer (rayomd --serve --json), which it downloads by default.

rayomd-mcp is an MCP server around RayoMD, the native Markdown-to-PDF converter: agents that write reports, summaries, release notes or documentation call markdown_to_pdf and get the PDF, its page count and what did not render. One warm rayomd process converts each document in a fraction of a millisecond; the server itself is one 460 KB JavaScript file on the official TypeScript SDK v2.

Highlights

Fast

A small note in 0.5 ms a call, end to end over stdio; ready 117 ms after start, the first call as fast as the rest.

Light

No headless browser, no TeX Live: one Node.js file and a 1.2 MB download of the static rayomd, fetched once and checked against its SHA-256.

Contained

Reads and writes only inside --root folders, resolved through links; URL images, themes and embedded sources off unless the server allows them.

Same PDF every run

Byte-identical to rayomd --export with the same flags, tested on six option sets, PDF/A and PDF/UA among them.

Everything RayoMD draws

TeX math, Mermaid diagrams, code coloured in 29 languages, tables of contents, PDF/A-3b and tagged PDF/UA-1.

Live preview

open_in_gui opens the note in RayoMD GUI, which follows each version the agent writes.

Related MCP server: Markdown2PDF MCP Server

Quick start

Always pass --root with the folders the agent may use: a desktop client starts servers in a working folder of its own choosing.

claude mcp add rayomd -- npx -y rayomd-mcp --root "$PWD"
{
  "mcpServers": {
    "rayomd": {
      "command": "npx",
      "args": ["-y", "rayomd-mcp", "--root", "/Users/me/Documents/reports"]
    }
  }
}

On Windows use "command": "cmd", "args": ["/c", "npx", "-y", "rayomd-mcp", "--root", "C:\\Users\\me\\Documents\\reports"].

{
  "servers": {
    "rayomd": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "rayomd-mcp", "--root", "${workspaceFolder}"]
    }
  }
}
npx @modelcontextprotocol/inspector npx -y rayomd-mcp --root .
npx @modelcontextprotocol/inspector --cli npx -y rayomd-mcp --root . --method tools/list

Node.js 20 or newer. The server downloads RayoMD 5.3.0 itself on the first call, or uses RAYOMD_PATH or rayomd on PATH (5.3.0 or newer):

git clone https://github.com/Butterski/rayomd-mcp && cd rayomd-mcp
npm ci && npm run build
node dist/rayomd-mcp.mjs --root ~/Documents/reports

In a client's configuration: "command": "node" and "args": ["/path/to/rayomd-mcp/dist/rayomd-mcp.mjs", "--root", "..."].

The server finds rayomd itself:

  1. RAYOMD_PATH, when set.

  2. Else rayomd on PATH (rayomd.exe on Windows).

  3. Else the RayoMD release pinned in this package, downloaded on the first call from GitHub releases (the static Linux x64 tarball, the Windows x64 zip), checked against the SHA-256 recorded in src/client/releases.ts and kept in ~/.cache/rayomd/bin/<version>/ ($XDG_CACHE_HOME/rayomd/bin, %LOCALAPPDATA%\RayoMD\cache\bin on Windows). A download whose hash differs is not used; after the first one the server works offline.

npx rayomd-mcp --install-binary does this at once and prints the binary's path, for machines that go offline later. macOS and Linux on ARM have no release binary: build rayomd from source and put it on PATH or in RAYOMD_PATH. A rayomd without --serve --json is reported as such in the tool's error.

Tools

Each tool answers with structuredContent (its outputSchema), a resource_link to the file written (a file:// URI) and one line of text. Failures are tool results with isError: true and a message the model can act on.

markdown_to_pdf

Markdown text (markdown) or a file (path) to the PDF output. Not read-only, not destructive, idempotent, not open-world.

{ "markdown": "# Q3 report\n\nRevenue grew $\\frac{3}{2}$ times.", "output": "q3.pdf", "toc": true, "page_numbers": true }

Argument

rayomd flag

markdown / path

exactly one of them

output

the PDF, ending in .pdf; an existing file is replaced

source_path

with markdown: the .md file the text stands for; relative images resolve from its folder. Default: output with .md

style

elegant modern tech

margin

compact normal wide margin=0.75in margin=54pt

page_size

--page-size=

a4 a3 a5 letter legal, -landscape, 210x297mm, 210mmxauto

toc, toc_depth

--toc, --toc-depth=N

number_headings

--number-headings=N

1 to 6 levels

page_numbers

--page-numbers

"N" ("N / M" up to RayoMD 5.3.0); a theme with footer-center = {page} / {pages} gives "N / M"

footnotes

--footnotes=end|page

dialect

--dialect=github|obsidian

pdfa, pdfua

--pdfa, --pdfua

black_text

--black-text

highlight_code: false

--no-highlight

diagrams: false

--no-diagrams

page_break_before

--page-break-before=hN

h1 to h6

allow_url_images

--allow-url-images

only with the server's --allow-url-images

allow_unsafe_local_images

--allow-unsafe-local-images

only with the server's --allow-unsafe-local-images

theme

--theme=FILE

only with --allow-theme; the file inside the roots

embed_source

--embed-source

only with --allow-embed-source

The answer is rayomd's --report record: input, output, status, code, pages, bytes, ms, missing_characters (characters no font had), failed_images (images printed as their alt text). The PDF is byte-identical to rayomd --export <file> <output> <flags> (for markdown, to --export of a file at source_path holding that text). The description carries a short form of the syntax reference.

book_to_pdf

inputs: one SUMMARY.md (mdBook, GitBook), one folder (its SUMMARY.md, else its Markdown files by name, README.md first) or Markdown files in order; output; the same options but embed_source. Runs rayomd --book <inputs> <output> <flags> once, without a shell; the files a SUMMARY.md lists or a folder holds must lie in that folder (rayomd checks). Answers inputs, output, pages, bytes, ms, missing_characters.

recover_markdown

pdf: a PDF exported with the source embedded (embed_source, so the server needs --allow-embed-source to make one, or one made by rayomd --embed-source). Without output the Markdown comes back as the result's text and in structuredContent.markdown; with output (a new .md file inside the roots) it is written there and never over an existing file. The PDF is not changed. It is not marked read-only because it can write that new file.

open_in_gui

path: a .md file inside the roots, opened in RayoMD GUI (RAYOMD_GUI_PATH, else rayomd-gui on PATH), started detached, without a shell. The GUI checks the file about once a second and reloads it when it changed on disk and its buffer has no unsaved edits, so the user sees each version the agent writes. Errors when the GUI is not installed, when there is no Wayland display on Linux, or when it exits at once.

Resource rayomd://syntax

What RayoMD renders (GitHub Markdown, alerts, footnotes, task lists, the TeX subset, Mermaid flowcharts, sequence diagrams and pie charts, code in 29 languages) and what degrades (HTML and CSS layout, LaTeX packages, other diagram types): the RayoMD skill's references/syntax.md, vendored in resources/syntax.md. Agents that read it write Markdown that renders instead of finding out from the PDF.

Security model

  • Roots. Files are read and written only inside the --root folders (repeatable; default the working folder). Relative paths resolve from the first root. Every path is resolved to its real location (.., symbolic links, junctions) before the check: an input must be a file whose real path lies in a root; an output's real folder must lie in a root, its name must end in .pdf (.md for recover_markdown), and an existing output that is a link, a folder or a file with other hard links is refused. MCP roots (deprecated in 2026-07-28, SEP-2577) are not used.

  • Images. rayomd loads local images only from the Markdown file's folder (source_path's for text), so they stay inside the roots too, and no URL images.

  • Off unless the server's command line turns them on: URL images (--allow-url-images), local images from anywhere (--allow-unsafe-local-images), theme files (--allow-theme, the theme file itself checked against the roots) and embedded sources (--allow-embed-source). Only then does the tool option exist. Tool calls never pass a raw flag to rayomd: every flag comes from a typed, validated option.

  • Processes. rayomd and the GUI are started with argument arrays, never through a shell. Warm rayomd --serve --json children serve the conversions from one queue, in order: a call goes to the first child that is free and has greeted, never to one still starting. The first child starts once the client has initialized (when a rayomd binary is already here); another starts, one at a time, only when calls have waited 5 ms for busy children without a break, up to --workers (default one a CPU, at most 4), and ends after 30 s idle. Calls for one output file run one after the other, in their order. book_to_pdf and recover_markdown take a slot of the same budget, so at most --workers rayomd processes work at once. A call the client cancels while it waits never reaches rayomd; a one-shot command it cancels is stopped. A child that exits, breaks the protocol or does not answer within the timeout (60 s, --timeout) is stopped and dropped, that call fails, and the calls behind it go to the other children. They end with the server.

  • Downloads. Only the pinned release asset, only when its SHA-256 matches.

Performance

Measured on 2026-11-04 on four pinned cores of an AMD Ryzen 5 PRO 4650GE in node:22-alpine (Node.js 22.23), with the static rayomd and a raw JSON-RPC client over stdio, as a desktop client talks to the server: the median of each run, the mean of two to four runs. Before is the first commit of this repository with RayoMD 426e4ed, the first --serve --json; after is this one with RayoMD b71ec98, its vectorized request reader.

Call

Before

After

Start until initialize is answered

182 ms

117 ms

First markdown_to_pdf (tester.md), 300 ms after initialize

18.2 ms

3.8 ms

Small Markdown text

0.69 ms

0.52 ms

Small Markdown file

0.53 ms

0.44 ms

1.1 MB Markdown text

30.5 ms

21.5 ms

7.9 MB Markdown text

606 ms

142 ms

1.1 MB Markdown files, 8 calls in flight

296 calls/s

545 calls/s

Of a small call, rayomd converts for 0.05 ms; the rest is the SDK's handling of the messages and the round trips through the pipes. What made the difference:

  • One file to load. dist/rayomd-mcp.mjs is one minified bundle of the server, the SDK and zod: Node.js reads, resolves and compiles one module instead of some 150. Most of what remains is Node.js's own start (54 ms) and the SDK building its schemas.

  • A warm first call. Once the client has initialized, the server starts the first rayomd and makes one call through a server of its own, in memory, into a temporary folder it deletes: the code of a call has run, its schemas are compiled and rayomd's fonts are loaded before the model's first call arrives.

  • Linear reads of large messages. The SDK's stdio reader copies everything it holds for each 64 KiB chunk and searches it from the start, and stops at 10 MB; src/stdio.ts keeps a message's chunks and joins them once, up to rayomd's 32 MiB request line.

  • System calls instead of thread-pool trips for the root checks, and no second check of a source_path that is the output's.

  • Children managed from one queue. A burst of calls is cleared by the warm child instead of waiting for new processes (each spawn holds Node.js's event loop about 0.75 ms), and a call no longer waits behind a slow build while another child is free:

    rayomd-mcp/client's pool, real rayomd

    One queue per child

    One queue

    8 small calls at once, one warm child: p50 / p99

    3.2 / 8.5 ms

    0.6 / 2.9 ms

    Small calls behind a 7.9 MB build, at most 2 children: p99

    31 ms

    7.5 ms

    Small calls, 8 in flight

    17,000 calls/s

    16,000 calls/s

    tester.md, 8 in flight

    5,100 calls/s

    5,000 calls/s

    With calls 1 ms apart behind a 7.9 MB build and up to four children, p99 went from 1.6 to 9.8 ms: the old pool had started four children for the earlier bursts, the new one starts the second only when calls wait. Through MCP the calls run at 3,100 to 3,600 a second either way: there the SDK, not the pool, sets the pace.

  • In rayomd: the request reader of --serve --json reads strings 16 bytes a step (SSE2) and decodes escapes in blocks: a 1 MB request of Markdown parses in 0.3 ms instead of 2.75.

A 1 MB request still spends about 5 ms in JSON.stringify of the Markdown on its way to rayomd: a raw-bytes frame would save it, at the cost of a stream that loses its place after a malformed line, so the protocol stays JSON.

Command line and environment

rayomd-mcp [--root DIR]... [--allow-url-images] [--allow-unsafe-local-images]
           [--allow-theme] [--allow-embed-source] [--timeout SECONDS] [--workers N]
rayomd-mcp --install-binary | --version | --help

Variable

RAYOMD_PATH

the rayomd executable

RAYOMD_GUI_PATH

the RayoMD GUI executable for open_in_gui

XDG_CACHE_HOME, LOCALAPPDATA

where the downloaded binary is kept

RAYOMD_FONT, RAYOMD_FALLBACK_FONT

read by rayomd itself: fonts for missing characters and PDF/A

The client library

rayomd-mcp/client is the binary resolver and --serve --json client on their own, for other programs (the RayoMD VS Code extension):

import { exportArgs, RayomdPool, resolveRayomd } from 'rayomd-mcp/client';

const rayomd = new RayomdPool({ command: async () => ({ command: (await resolveRayomd()).path }) });
const record = await rayomd.request({ input: 'notes.md', output: 'notes.pdf', args: exportArgs({ toc: true }) });
console.log(record.status, record.pages);
await rayomd.close();

request(…, { signal }) drops a call that still waits when the signal aborts, and run(signal => …, { signal }) runs a one-shot command in a slot of the same budget; the pool's options are maxChildren, idleMs, startAfterMs, requestTimeoutMs and startTimeoutMs. RayomdServe is one child on its own; the module also exports runRayomd (one command, no shell, stopped by a signal), downloadRelease, findOnPath, RELEASE_SHA256 and the archive readers.

Development

npm ci
npm test                                        # build, unit tests against test/fake-rayomd.mjs
RAYOMD_TEST_BINARY=/path/to/rayomd npm test     # and the real-binary suite (byte-identical PDFs)
RAYOMD_PATH=/path/to/rayomd npm run smoke       # raw JSON-RPC over stdio against dist/rayomd-mcp.mjs
npm run sync-syntax -- ../rayomd/skills/rayomd/references/syntax.md
npm run pin-release -- 5.3.0                    # pin a release's asset hashes and download it by default

A change to the call path comes with before and after numbers, measured as above. A release: bump version in package.json and both versions in server.json, tag vX.Y.Z; release.yml publishes to npm with provenance and to the MCP Registry.

License

Apache-2.0, as RayoMD. See LICENSE.

Available Tools

4 tools
book_to_pdfBook to PDFA
Idempotent

Makes one PDF of several Markdown files: each from a new page, links between them kept, one outline (and with toc one table of contents). The files a SUMMARY.md lists or a folder holds must lie in that folder.

Inputs: inputs (required), output (required), toc, pdfa, +13 more. Returns: ms, code, bytes, pages, +4 more

markdown_to_pdfMarkdown to PDFA
Idempotent

Converts Markdown (text or a file) to a PDF with RayoMD and returns the PDF's page count and warnings. Renders: GitHub Markdown (tables, task lists, footnotes, alerts > [!NOTE]), PNG/JPEG/SVG images with alt text (relative paths inside the Markdown file's folder), TeX math ($...$, $$...$$ on own lines, math), mermaid flowchart/graph, sequenceDiagram and pie, code colouring in 29 languages, page breaks (\pagebreak, ), [TOC], YAML front matter (title, author, lang) as PDF metadata. Degrades: CSS/HTML layout (text kept), LaTeX packages and macros, other Mermaid types (printed as code), SVGs needing scripts. Full list: resource rayomd://syntax.

Inputs: output (required), toc, path, pdfa, +15 more. Returns: ms, code, bytes, error, +6 more

open_in_guiOpen in RayoMD GUIA
Read-only

Opens a Markdown file in RayoMD GUI, the desktop editor with a live PDF preview, for the user to read or edit. The GUI checks the file about once a second, focused or not, and reloads it when it changed on disk and its buffer has no unsaved edits, so a file the agent rewrites shows the new version. Needs RayoMD GUI installed (rayomd-gui on PATH or RAYOMD_GUI_PATH) and a desktop session (Wayland on Linux).

Inputs: path (required). Returns: gui, pid, file

recover_markdownRecover Markdown from a PDFA

Gets back the exact Markdown source of a reversible PDF (one exported with the source embedded), checked against its digest. Returns the text, or writes it to a new .md file; the PDF is not changed.

Inputs: pdf (required), output. Returns: bytes, input, output, markdown

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: single-file conversion, multi-file book conversion, source recovery, and GUI opening. The descriptions explicitly clarify boundaries, especially between markdown_to_pdf and book_to_pdf.

    Naming Consistency4/5

    Names are all snake_case and descriptive, but the convention mixes source_to_target names (markdown_to_pdf, book_to_pdf) with verb_object names (recover_markdown, open_in_gui). The pattern is still readable and logical.

    Tool Count5/5

    Four tools are well-scoped for a Markdown-to-PDF conversion server. Each tool covers a distinct workflow without unnecessary surface area.

    Completeness5/5

    The surface covers the core lifecycle: convert a single Markdown file, convert a multi-file book, recover embedded Markdown from reversible PDFs, and open files in the GUI for preview/editing. No obvious dead ends for the stated purpose.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers