PostScript MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PostScript MCP Validate this PostScript and point out any errors before I send it."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostScript MCP
An MCP server that gives AI agents the tools to write high-quality PostScript — grounded in the Adobe manuals and Kees van der Laan's PSlib rather than guessed from memory.
It exposes four capabilities:
Capability | Tools | What it does |
Render & validate |
| Run a program through Ghostscript, get a PDF/PNG/SVG and structured diagnostics — the write→check→fix loop that lets an agent self-correct. |
Operator lookup |
| Exact PLRM operator definitions (stack signature, LanguageLevel, errors). 270 operators shipped, offline. |
PSlib fragments |
| Retrieve van der Laan's vetted procedures by name, with their stack signatures and source, so agents reuse code instead of reinventing it. |
Reference search |
| Cited passages from the PLRM, Blue/Green books, DSC/EPS specs and tutorials. |
Plus postscript_capabilities for setup/debugging.
Why
LLMs write plausible-looking PostScript that fails on a real interpreter:
wrong operand order, undefined names, unbalanced gsave/grestore, EPS files
with no %%BoundingBox. This server closes that gap. The agent can confirm an
operator's signature before using it, paste in a procedure that is known to
work, quote the spec when behaviour is subtle, and — crucially — actually run
the program and read the errors back before handing code to a human.
Pair it with the skill suite for the authoring conventions.
Related MCP server: Typst MCP Server
Requirements
Python 3.10+
Ghostscript — the
gsbinary (rendering & validation)macOS:
brew install ghostscript· Debian/Ubuntu:apt install ghostscriptWindows: the official installer, then ensure
gswin64c.exeis onPATH
pdftotext (poppler-utils) — only needed to build the reference corpus
macOS:
brew install poppler· Debian/Ubuntu:apt install poppler-utils
Install
cd postscript-mcp
python -m venv .venv && source .venv/bin/activate # optional
pip install -e . # installs the `mcp` depThat is enough for operator lookup and render/validate to work
immediately (the operator dataset ships in data/operators.json).
Build the indexes (PSlib + reference corpus)
Point the ingester at your PostScript reference library — the folder with the
Adobe PDFs and the PSlib sources (this project was built around exactly such a
library; see the accompanying REFERENCE_INDEX.md):
python scripts/ingest.py --library "/path/to/postscript reference"This writes:
data/pslib_index.json— every PSlib procedure, parsed fromPSlib.ps/PSlib.eps(auto-discovered; or pass--pslib PSlib.ps).corpus/corpus_index.json— one searchable chunk per PDF page and per block of each.ps/.txtsource.
Re-run it whenever your library changes. Useful flags: --skip-corpus,
--skip-pslib, --pslib <files…>, --library, --corpus, --data.
You can also set defaults via environment variables (below) instead of flags.
Connect it to a client
Claude Desktop
Edit claude_desktop_config.json
(macOS: ~/Library/Application Support/Claude/,
Windows: %APPDATA%\Claude\):
{
"mcpServers": {
"postscript": {
"command": "python",
"args": ["-m", "postscript_mcp"],
"env": {
"PSMCP_LIBRARY_DIR": "/path/to/postscript reference",
"PSMCP_DATA_DIR": "/path/to/postscript-mcp/data",
"PSMCP_CORPUS_DIR": "/path/to/postscript-mcp/corpus"
}
}
}
}If you installed with pip install -e ., you can use the console script
instead: "command": "postscript-mcp", "args": []. Point command at the
Python inside your virtualenv if you used one.
Claude Code
claude mcp add postscript -- python -m postscript_mcp(run from the project directory, or give the absolute interpreter path).
Any MCP client
The server speaks MCP over stdio: launch python -m postscript_mcp.
Remote / cloud deployment (public HTTPS endpoint)
To expose this server on the network so any client can reach it over HTTP, see
the deployment guides. It serves MCP over Streamable HTTP at /mcp,
containerised with Docker (Ghostscript included):
DEPLOY_RENDER.md— recommended, free, no credit card: deploy to the Render free tier (GitHub sign-in) and point your own domain at it.DEPLOY.md— alternative: a free Oracle Cloud Always Free VM running Docker + Caddy (TLS).
{
"mcpServers": {
"postscript": {
"type": "http",
"url": "https://mcp.example.com/mcp"
}
}
}Tool reference
validate_postscript(source="", path="") → {ok, diagnostics[], bbox, hires_bbox, hint, …}
Interpret without rasterising (fast). Diagnostics carry error,
offending_command and whether it is a genuine interpreter error. hint
gives a plain-language nudge for common failures. Great for filling an EPS
%%BoundingBox from hires_bbox.
render_postscript(source="", path="", output_format="png", resolution=150, page=None, eps_crop=True, return_base64=False) → {ok, output_path, page_count, bbox, diagnostics[], …}
output_format ∈ png, png-alpha, pdf, svg. Returns the output file
path; set return_base64=True to also get PNG bytes inline.
lookup_operator(name) → the operator's signature, operands,
results, summary, category, level, errors. On a miss, returns
did_you_mean.
search_operators(query, category="", limit=20) → ranked operators, or a
whole category listing.
get_pslib_fragment(name) → {signature, source, category, attribution, line} for one PSlib procedure.
search_pslib(query="", category="", limit=20) → matching procedures
(names + one-line signatures); follow up with get_pslib_fragment.
search_reference(query, limit=8, doc="") → cited passages
{doc, page, snippet, score}. Restrict to a document with doc (e.g.
"PLRM", "Green", "DSC").
postscript_capabilities() → what is available right now (Ghostscript
present? indexes built?) and how to build what is missing.
Recommended agent workflow
Draft using
lookup_operator/search_pslib+get_pslib_fragment.Consult
search_referencewhen behaviour is subtle (imaging model,save/restore, DSC rules).Check with
validate_postscript— fix every diagnostic.Render with
render_postscriptand, for figures, verify the bounding box and that the image looks right.For embeddable output, emit a correct
%%BoundingBoxand DSC comments (seeexamples/square.eps).
Configuration (environment variables)
Variable | Default | Purpose |
|
| Where your reference PDFs / PSlib sources live (for ingest). |
|
| Location of |
|
| Location of the search corpus. |
| auto-detected | Path to the |
| temp dir | Where rendered files are written. |
|
| Ghostscript wall-clock limit (seconds). |
|
| Max program size accepted. |
Safety
Every Ghostscript invocation uses -dSAFER (no arbitrary file writes / device
control from the program) and a wall-clock timeout, and source size is capped.
The server never executes PostScript except through Ghostscript.
Development
pip install -e ".[dev]"
python scripts/gen_operators.py # regenerate data/operators.json
python -m pytest -q # run the test suiteLayout
postscript_mcp/ server + the four capability modules
server.py FastMCP wiring (the tools)
render.py Ghostscript validate/render
operators.py operator reference access
pslib.py PSlib tokeniser / parser / index
reference.py BM25 corpus search
config.py paths & limits from env
data/operators.json curated PLRM operator reference (shipped)
scripts/ingest.py build pslib_index.json + corpus from your library
scripts/gen_operators.py rebuild the operator dataset
skills/ agent skill suite (see below)
examples/ conformant EPS + PSlib usage
tests/ pytest suite (+ a real PSlib fixture)Skills
The skills/ folder holds a composable suite an agent loads alongside this
server:
postscript-authoring — stack discipline, structure, the render/verify loop.
postscript-pslib — reusing van der Laan's library correctly.
postscript-eps-dsc — conformant EPS / DSC output for embedding & print.
Credits & licences
PSlib © Kees van der Laan (kisa1@xs4all.nl) — parsed and indexed here for reference; its own terms apply to the code itself.
Operator reference curated from the PostScript Language Reference Manual, 3rd ed. (Adobe, 1999).
This server's code: MIT (see
LICENSE).
Available Tools
8 toolsget_pslib_fragmentA
Return a PSlib procedure by name, with its stack signature and source.
PSlib is Kees van der Laan's library (colours, geometry such as circle
inversion and Apollonius, Lauwerier fractals, Blue-Book text/graphics
helpers). Reuse these vetted procedures instead of reinventing them.
The source is ready to paste; include the whole library at run time
with e.g. (PSlib.eps) run.
Inputs: name (required).
lookup_operatorA
Return the exact PLRM definition of a PostScript operator.
Gives the stack signature (operands operator results), a summary, the LanguageLevel it requires, and the errors it can raise. Use this to get operand order and types right instead of guessing.
Example: lookup_operator("arc") → signature "x y r ang1 ang2 arc -", category "path", level 1.
Inputs: name (required).
postscript_capabilitiesA
Report what this server can currently do (for setup/debugging).
Tells you whether Ghostscript is available for rendering, how many operators are loaded, whether the PSlib index and reference corpus have been built, and how to build them if not.
Inputs: no named parameters.
render_postscriptA
Render a PostScript/EPS program to a PDF, PNG or SVG file.
output_format is one of: "png", "png-alpha", "pdf", "svg".
resolution is DPI for raster output. page (1-based) renders a single
page. eps_crop trims to the bounding box (good for EPS figures).
Set return_base64 to also receive PNG bytes inline for quick preview.
Provide EITHER source or path. The output file path is returned so a
human can open it. Diagnostics are reported the same way as
validate_postscript — always check ok and fix any diagnostics.
Inputs: page, path, source, eps_crop, +3 more.
search_operatorsA
Search PostScript operators by keyword or browse a category.
Pass a query (e.g. "rotate", "fill path", "cmyk") to rank operators by
relevance, or a category to list it. Categories include: stack, math,
array, dict, string, boolean, control, type, file, vm, gstate, color,
matrix, path, paint, text, font, device, resource, misc.
Inputs: query (required), limit, category.
search_pslibA
Search or browse PSlib procedures.
Pass a query (e.g. "dragon", "circle inversion", "cmyk colour") or a
category (color, fractal, geometry, text, complex, linalg, arrow,
units, util, misc). Returns names with one-line signatures; call
get_pslib_fragment to retrieve full source.
Inputs: limit, query, category.
search_referenceA
Search the PostScript reference corpus and return cited passages.
Covers whatever was ingested: the PLRM, the Blue and Green books, the
DSC and EPS specifications, and the tutorials. Optionally restrict to one
document with doc (substring of its name, e.g. "PLRM", "Green",
"DSC"). Each hit includes the document, page/block number and a snippet
so you can cite the spec precisely.
Inputs: query (required), doc, limit.
validate_postscriptA
Interpret a PostScript/EPS program WITHOUT rasterising and report errors.
This is the fast self-check to run before presenting any PostScript. It uses Ghostscript's bbox device, so it catches real interpreter errors (undefined names, stack underflow, type errors, unbalanced save/restore) and returns the computed bounding box — useful for setting an EPS %%BoundingBox.
Provide EITHER source (the program text) or path (a file on disk).
Returns: {ok, diagnostics[{error, offending_command, message, is_postscript_error}], bbox, hires_bbox, hint, ghostscript_stderr}.
Inputs: path, source.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct job: exact operator definitions vs operator search, validation vs rendering, PSlib retrieval vs searching, and reference/capability lookups. Even the paired search/get tools are clearly separated by role.
Most tools follow a consistent verb_noun pattern (lookup_operator, validate_postscript, search_operators). The only deviation is postscript_capabilities, which lacks a verb; otherwise the naming is uniform and predictable.
Eight tools is an appropriate size for a PostScript assistant: each one covers a necessary stage of authoring, checking, rendering, and reference lookup without redundancy. The count feels intentional rather than padded.
The surface covers a full workflow: discover operators, validate code, render output, reuse library procedures, and consult authoritative references. There are no dead ends or obvious missing operations for the stated domain.
Maintenance
Related MCP Connectors
PDF tools for AI agents: validate, extract, merge, split, compress, OCR, sign and redact.
PDF and image tools for AI agents: compress, merge, split, OCR, sign. Runs locally, never uploads.
PDF, image, video, OCR, screenshot, SQL, QR and text tools for agents. No API key, no signup.
Image & PDF tools for AI agents: compress, convert, resize, PDF, AI vision, pipeline.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables AI models to convert LaTeX snippets into Typst, validate Typst syntax, browse the official Typst documentation, and render Typst code to PNG images. This lets models verify typeset output and check code correctness before delivering it to users.-
- FlicenseNot gradedqualityAmaintenanceEnables AI models to interact with Typst by converting LaTeX snippets to Typst, validating Typst syntax, reading Typst documentation, and rendering Typst code as PNG images.-
- FlicenseNot gradedqualityAmaintenanceEnables AI models to interact with the Typst typesetting system by converting LaTeX snippets, validating Typst syntax, and rendering Typst code to images.-
- FlicenseNot gradedqualityAmaintenanceEnables AI models to work with Typst by retrieving documentation, converting LaTeX snippets to Typst, validating Typst syntax, and rendering Typst code as PNG images.-