typst-mcp

v1.3.1
typst-mcp Checked 1 day ago Published 1 month ago

Model Context Protocol (MCP) server for https://typst.app/ cloud projects, Yjs real-time text editing, asset management, and Typst compiler diagnostics

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

typst_auth_login

Authenticate with https://typst.app using direct email/password API login (POST /v1/auth/signin) or a session cookie (__Http-typst-session), with automatic cookie/browser fallback on challenge.

ParameterTypeDescription
emailstringTypst account email (falls back to TYPST_EMAIL env var)
passwordstringTypst account password (falls back to TYPST_PASSWORD env var)
sessionCookiestringOptional __Http-typst-session cookie value or full Cookie header string (falls back to TYPST_SESSION_COOKIE)
useBrowserFallbackbooleanEnable automatic fallback if Turnstile/CAPTCHA challenge blocks direct HTTP login (default: true)

typst_auth_status

Check current https://typst.app authentication status, active session cookies, and login method.

typst_list_projects

List all owned and shared/external projects in the authenticated user's https://typst.app dashboard.

typst_get_project

Get detailed metadata, access permissions, pinned compiler version, and full file tree for a https://typst.app project.

ParameterTypeDescription
projectId *stringThe Typst project ID

typst_create_project

Create a new project on https://typst.app with optional initial .typ/.bib files and pinned Typst compiler version.

ParameterTypeDescription
name *stringProject title
filesarrayOptional initial text files (defaults to main.typ)
folderstringOptional folder ID
ownerstringOptional owner user/team ID
pinnedVersionstringTypst compiler version (default: 0.15.1)

typst_delete_project

Permanently delete a project on https://typst.app by ID.

ParameterTypeDescription
projectId *stringThe Typst project ID to delete

typst_list_files

List all files (multiplayer Yjs text files and binary asset blobs) inside a https://typst.app project.

ParameterTypeDescription
projectId *stringThe Typst project ID

typst_read_file

Read project text in bounded pages (default 200 lines/16 KiB) or images as native image blocks. content contains source only; use nextOffset for continuation. contentHash covers the entire raw text file: pass it as expectedHash to typst_edit_file. Compact file metadata by default; output='full' adds metadata, not extra source lines. Use grep to locate relevant lines before reading large files.

ParameterTypeDescription
filePath *stringFile path/name (e.g. 'main.typ') or file ID
projectId *stringThe Typst project ID
limitintegerMaximum complete lines to read (default: 200). Use nextOffset to continue.
lineNumbersbooleanWhether to prefix each line with its 1-indexed line number (e.g. '1 | ')
maxBytesintegerMaximum returned source bytes, including line number prefixes (default: 16384, maximum: 1 MiB). Increase for unusually long lines.
offsetintegerLine number to start reading from (1-indexed)
outputstringcompact (default): minimal file metadata; full: all file metadata. Both use offset/limit/maxBytes pagination.

typst_write_file

Create or overwrite a text file (.typ, .bib, .toml, etc.) in a https://typst.app project, synchronizing the Yjs CRDT update via WebSocket (/editing/v3) and REST (/v1/files/:projectId/:fileId/yjs).

ParameterTypeDescription
content *stringFull UTF-8 text content to write
filePath *stringFile path/name (e.g. 'main.typ') or file ID
projectId *stringThe Typst project ID
preferWebSocketbooleanAlso push real-time TextUpdate over /editing/v3 WebSocket before REST persistence (default: true)

typst_edit_file

Apply all targeted edits against one original file snapshot, with one save. Prefer short unique oldText anchors and expectedHash from typst_read_file to reject stale edits. Exact matching by default (LF/CRLF resilient); matchMode='fuzzy' opts into Unicode/whitespace fallback. Malformed, ambiguous, or overlapping edits fail without saving. Summary output by default; dryRun previews a bounded diff. Unchanged characters and BOM are preserved.

ParameterTypeDescription
dryRunbooleanValidate and preview edits without saving (default: false). Returned contentHash still identifies unchanged cloud text.
editsarrayOne or more targeted non-overlapping replacements. Each oldText must be unique in the original file.
expectedHashstringRecommended: contentHash from the latest read. Checked against fresh downloaded text inside the file mutation queue; stale files fail without saving.
filePathstringFile path/name (e.g. 'main.typ') or file ID
matchModestringexact (default) matches source with newline normalization. fuzzy enables Unicode quote/dash/space/NFKC fallback only when an exact match is absent.
maxDiffBytesintegerByte budget per diff/patch field (default: 8192). Each also has a 100-line cap. Truncation is explicit; read affected ranges for full details.
newTextstringOptional replacement text for single replacement shorthand
oldTextstringOptional shorthand for a single replacement (used if edits is omitted)
outputstringsummary (default): counts, new contentHash, firstChangedLine; diff: also a bounded display diff; full: also bounded patch and full metadata. dryRun defaults to diff.
preferWebSocketbooleanPush real-time TextUpdate over /editing/v3 WebSocket in addition to REST persistence (default: true)
projectIdstringThe Typst project ID

typst_upload_asset

Upload or replace a binary asset (PNG, JPG, SVG, PDF, font, etc.) in a https://typst.app project from a local file path or base64 data.

ParameterTypeDescription
fileName *stringDestination path inside the Typst project (e.g. 'figures/plot.png')
projectId *stringThe Typst project ID
base64DatastringBase64-encoded binary payload (used if localFilePath is not provided)
convertbooleanWhether typst.app should convert the uploaded file
localFilePathstringLocal filesystem path to read binary asset bytes from

typst_delete_file

Delete a file or asset from a https://typst.app project via DeleteFilesMutation.

ParameterTypeDescription
filePath *stringFile path/name or file ID to delete
projectId *stringThe Typst project ID

typst_rename_file

Rename or move a file inside a https://typst.app project via UpdatesFileMutation.

ParameterTypeDescription
filePath *stringExisting file path/name or file ID
newName *stringNew destination path/name inside the project
projectId *stringThe Typst project ID

typst_get_diagnostics

Retrieve compiler diagnostics (errors, warnings, line/column numbers, and hints) for a https://typst.app project. Supports both local Typst CLI compilation (fastest) and Typst Web cloud diagnostics (zero-binary fallback using typst.app cloud compiler).

ParameterTypeDescription
projectId *stringThe Typst project ID
mainFilestringOptional main .typ entry file override (defaults to project previewed file or main.typ)
modestringDiagnostics mode: 'auto' (prefers local Typst CLI if installed, falls back to Typst Web cloud compiler), 'cli' (requires local typst binary), or 'web' (uses Typst Web cloud compiler). Defaults to 'aut…

typst_export_pdf

Synchronize all text and binary files from a https://typst.app project, compile the document to PDF, and save it to outputPath.

ParameterTypeDescription
projectId *stringThe Typst project ID
mainFilestringOptional main .typ entry file override
outputPathstringOptional local filesystem path to save the compiled PDF

typst_capture_screenshot

Capture high-resolution PNG preview screenshots to verify the visual status of a https://typst.app project (mode='pages' renders compiled PNG pages via Typst; mode='browser' captures the live typst.app web editor & preview pane via Playwright).

ParameterTypeDescription
projectId *stringThe Typst project ID
includeBase64booleanInclude screenshots as image blocks for direct vision inspection (default: true; set false to return paths and metadata only)
mainFilestringOptional main .typ entry file override
modestring'pages' (default) compiles high-DPI PNG pages from synced project files; 'browser' captures the live https://typst.app/project/:id UI
outputDirstringOptional directory path to save the rendered PNG screenshot files
pagesstringPage range to capture, e.g. '1', '1-3', '1,4', or 'all' (default: 'all')
ppinumberPixels per inch resolution for rendered PNGs (default: 144)

typst_grep_project

Search for text or regular expressions across files in a https://typst.app project. Returns matching lines with file paths, line numbers, and optional surrounding context lines.

ParameterTypeDescription
pattern *stringSearch pattern (regular expression or literal string)
projectId *stringThe Typst project ID
contextnumberNumber of lines to show before and after each match (default: 0)
globstringOptional glob pattern to filter files (e.g. '*.typ' or '*.bib')
ignoreCasebooleanCase-insensitive search (default: false)
limitnumberMaximum number of matches to return (default: 100)
literalbooleanTreat pattern as literal string instead of regex (default: false)
pathstringOptional directory or file path to restrict search (e.g. 'chapters/' or 'main.typ')

typst_find_and_replace

Find and replace text or regex in one file or project-wide. Use replacements to batch mappings (e.g. Sep → September, Oct → October) in one call with one save per file. Rules run sequentially; later rules see earlier results. Batch output defaults to compact summary; request output='diff' or 'full' for previews. Supports dryRun and per-file mutation serialization. Project-wide changes are not atomic across files.

ParameterTypeDescription
projectId *stringThe Typst project ID
dryRunbooleanIf true, returns unified diffs and match counts without saving changes (default: false)
filePathstringOptional file path/name (e.g. 'main.typ'). If omitted, searches and replaces across all text files in the project.
globstringOptional glob pattern to filter target files when searching project-wide (e.g. '*.typ')
ignoreCasebooleanCase-insensitive search (default: false)
limitnumberMaximum number of replacements per file (default: replace all occurrences)
outputstringsummary: counts and first changed line; diff: also display diff; full: also unified patch. Defaults to summary for batches, full for legacy pattern/replacement calls. Applies to dry runs too.
patternstringSearch pattern to replace (literal substring or regex)
preferWebSocketbooleanPush real-time TextUpdate over /editing/v3 WebSocket before REST persistence (default: true)
regexbooleanWhether pattern is a regular expression (default: false)
replacementstringReplacement text (supports $1, $2 capture groups if regex is true)
replacementsarrayOrdered replacement rules instead of pattern/replacement. Each rule runs on the previous result. Set regex, ignoreCase, and limit per rule. All rules are validated before any writes; each changed file…