Galley MCP
This is Galley’s local MCP kernel: it exposes a shared Typst project to an external agent for inspection, proposal-based editing, and compile diagnostics.
Ping the kernel to check liveness and version.
List the reachable project and get its
projectIdand main file.List project files with exact paths, sizes, binary-file pointers, and duplicate-path flags.
Read text files by exact path; binary files return metadata only, and oversized files are refused.
Query project context for relevant excerpts across all files with file path, line range, and Typst heading provenance.
Propose single-file edits via exact search/replace blocks for human review, or guarded auto-accept if armed.
Propose atomic multi-file changes: create, edit, rename/move, delete, and add binary files from base64 or a local absolute path.
Compile/type-check the project and return diagnostics plus page count without modifying the document.
Respect the review gate: it does not write directly; proposals await human Accept unless the project has agent auto-accept armed.
Allows using a local Ollama instance as the AI provider for Galley's document editing agent.
Allows using OpenAI or any OpenAI-compatible endpoint as the AI provider for Galley's document editing agent.
Allows importing Overleaf projects into Galley via .zip archives.
Allows importing references from Zotero/BibTeX (.bib) libraries into Galley.
The workspace above is the bundled Annus Mirabilis demo: multiple Typst files, a real nine-page compile, source editing and the offline Demo agent. Open Files on the left rail to navigate the project; use Export for the finished document or ⌘K / Ctrl+K to find an action.
The offline Demo model proposes a sample section without an API key. In Ask mode, inspect the compiled proposal and choose Accept or Reject. The screenshot was taken before Accept; the capture also verified that accepting updated the document, compiled cleanly and survived a reload.
In Settings → Appearance, choose Studio or Press, then Light, Dark or System. Artwork and Plain control the desk background independently. These choices change the workspace; document styling stays in Typst and the Change style command.
A galley proof is the preliminary typeset version you check and correct before final layout — which is exactly this app's core loop: compile → inspect → correct → repeat.
Galley is, conceptually, "AI-enhanced ShareLaTeX, but Typst instead of LaTeX, open source, and not locked to one vendor's cloud or model." The differentiation is three bets a cloud-only, single-vendor product structurally cannot make:
Agentic, not autocomplete. Typst compiles in milliseconds and emits structured, machine-readable diagnostics. That makes a tight edit → compile → read errors → self-correct loop cheap. That loop is the product.
Local-first. The Typst compiler runs in the browser via WASM (
typst.ts). Your document and your compile stay on your machine. Server-side compile is an optional enhancement, never a dependency. (See the honest local-first definition — remote model endpoints still receive your document.)Bring-your-own-model. A provider abstraction runs the agent against any OpenAI-compatible endpoint, Anthropic, or a local Ollama. Model choice is config, never a fork.
Status
Galley works end-to-end in the browser today: a CodeMirror editor with a live
SVG preview (typst.ts compiling in a Web Worker) and the human-in-the-loop
agent loop — request → self-correct → diff → Accept/Reject → re-render.
Bring your own model (any OpenAI-compatible endpoint, Anthropic, or a local
Ollama) or use the built-in offline Demo agent. Real-time collaboration is
opt-in — one-click Share upgrades a project to Yjs CRDT co-editing with the
agent as a peer, presence, and per-author attribution (ADRs
0005–0012). Multi-file projects and templates, named versions
with visual compare, broad import/export (Markdown, LaTeX, Overleaf .zip,
Zotero/.bib and native source .tar in; PDF/PNG, source bundles and Git projections out), and opt-in MCP access behind an explicit
consent gate round it out. Self-host with Docker compose or Kubernetes; the
whole test suite (typecheck + unit + Playwright e2e) runs in Docker. See
the CHANGELOG for the full feature inventory and the
roadmap for what's next.
Review the document before sharing
The writing/agent pane has deterministic, offline review tools. Open Agent panel from the left rail if that pane is hidden.
Open | What you can review |
Before you send | Current preview SVG page count and optional portrait A4/Letter checks, plus source editorial markers. Results distinguish passed, failed and unavailable; stale previews do not pass. PDF export is compiled separately. |
Meaning changes to check in a proposal diff | Changed numbers, dates, units, citation keys and selected obligation/negation words alongside the normal diff. These are attention flags, not semantic or factual verification. |
Document workbench → Living numbers | Import project CSV/JSON, name a scalar and link its exact document passage. Changed source versions flag potentially stale prose; preview and Accept a compiled refresh. |
Document workbench → Evidence lens | Manually link a claim passage to a retained source version and excerpt, mark your review, and see changed or unavailable links. This records a review decision, not an automatic fact-check. |
Layout auditions on the project main document | Compile three local scratch margin variants, compare previews and page caps, then review and Accept one. Original wording/assets/text-size rules stay intact; minimum rendered font size is not verified. |
Document workbench → Reviewer response desk | Paste comments, link passages, track resolutions, review proposed revisions and draft replies; use Download response letter for Markdown export. |
Workbench revisions and layout auditions require a successful local scratch compile and explicit Accept. Accept rechecks current source/project input, including main entry and resolved asset bytes, before any live write. Missing or changed dependencies require a new preview. These tools do not certify PDF compliance, claim truth or minimum font size.
Workbench records live in the canonical project CRDT and retain their source
versions. Native source bundles and Git projections carry only the validated
known .galley/workbench.json record alongside existing export contracts;
device/secret metadata stays excluded. Native import preserves source paths,
contents and binary bytes through the review-and-Accept flow. See
document checks and layout auditions and the
workbench workflows and limits.
Default product & routes
Galley uses path-based routes (a tiny History-API router):
/— the Projects page, the landing surface (create / open / import projects)./p/<id>— a specific local-first project (auto-saved to the browser, reload-survivable). On a self-hosted instance with sign-in, the server also keeps a copy of its text by default, so clearing the browser's data does not lose it; hosted asset storage also copies images and project fonts. Each project can opt out across the account (ADR-0035)./library— the project dashboard./join/<room>— share-link entry (joins a collaboration room; carries?sync=/?role=)./c/<id>— one of your connected projects, opened from its server copy on a device that does not hold it (hosted connector without server copies; with them, the project is restored to/p/<id>)./settings— device-scoped settings./settings/whats-new— recent features, linked from Settings.
Collaboration is an explicit Share action, never on by default. The only
editor-on-home hatch is ?seed=… (the seeded Einstein showcase, also the e2e entry).
Related MCP server: mcp-server-test
The core loop
User request
│
▼
Agent proposes edits (search/replace blocks)
│
▼
Apply to a SCRATCH copy ──► compile ──► read diagnostics
│ │
│ ◄── errors? revise (up to MAX_ITERS) ─┘
▼
Clean compile → present a reviewable diff
│
▼
User clicks Accept ──► apply to live document
or Reject ──► discard scratchAsk is the default: proposals wait for human Accept or Reject. Explicit per-project Auto settings for the in-app agent and separately authorized MCP grants use the established guarded acceptance paths, with checkpoints and Undo; MCP proposals additionally require authenticated provenance. See the acceptance decision and security model. Workbench revisions and layout auditions retain their explicit human review gate.
Bring your own agent (no API key)
A configured cloud model usually needs a provider API key and may charge per token; the offline Demo agent and suitable local models do not. You can also use an agent you already run: Galley ships a local MCP kernel that carries no model at all. No provider, no key, no inference. It is a bridge that exposes your project as tools to an agent you already run, so Claude Code or Codex drives Galley on the plan you already pay for.
# One-time: install the kernel's bin from your checkout
cd apps/mcp && pnpm link --global
# Share the project in the browser to mint a room id, then:
claude mcp add galley -- galley-mcp \
--sync ws://localhost:1234 --room <room-id> --file /main.typYour agent gets the live document, the file tree, query-relevant excerpts across
files, and real Typst diagnostics, through the same tool list the hosted
connector serves. What it does not get is write access:
propose_edit and propose_files publish a pending review card, and a human
clicks Accept. That gate is structural, not a preference.
Control mode goes further and lets the agent list your library and ask to open a project, behind a one-time pairing code, per-project read grants that default to zero, and a blocking confirmation for every open.
→ Use your own coding agent with Galley for the walkthrough, or the full kernel reference for every flag.
Monorepo layout
galley/
├─ apps/
│ ├─ web/ # React + Vite app: editor, preview, agent panel, diff UI
│ ├─ web-server/ # tiny Hono static server for the built SPA (self-host runtime)
│ ├─ sync/ # @galley/sync — optional y-websocket collaboration server
│ ├─ compile/ # optional server-side Typst compile service (Hono + @galley/compiler)
│ ├─ proxy/ # thin, optional, self-hostable model-API proxy (keys off the browser)
│ └─ mcp/ # inbound MCP local kernel: exposes the agent tools to external MCP clients
├─ packages/
│ ├─ compiler/ # typst.ts wrapper: check(), render(), export() — in a Worker
│ ├─ agent/ # agent loop, tools, provider abstraction
│ ├─ collab/ # Yjs CRDT doc, presence, and cross-peer author attribution
│ ├─ auth/ # generic OIDC (Auth Code + PKCE) auth core
│ ├─ persistence/ # ProjectStore / CrdtStore / VersionStore adapters
│ └─ shared/ # cross-package types: Diagnostic, EditBlock, AgentEvent, …
├─ docs/ # foundation docs (start here ↓)
├─ AGENTS.md # rules for AI agents working ON this repo
└─ CONTRIBUTING.mdcompiler and agent are framework-agnostic (no React) so they can be reused
server-side. The optional server pieces — apps/proxy (model proxy, keys off the
browser), apps/sync (collaboration relay), and apps/compile (server-side
compile) — are self-hostable and used only when configured. The sync relay can
optionally persist project state; the proxy is stateless. The default browser
single-user path needs none of them (see the ADRs).
Documentation
Read these in order:
Doc | Purpose |
Product principles, the three bets, non-goals, honest definitions | |
Package boundaries, data flow, the worker model, source-of-truth rules | |
What's built, what activates with config, future directions | |
Threat model, per-surface posture, deployment hardening checklist | |
Docker compose + Kubernetes packaging | |
Server topology, accounts/auth, Yjs collaboration, agent-as-peer (design rationale) | |
The agent state machine, tools, iteration/error/cancel handling, event stream | |
Search/replace contract, scratch isolation, diff, Accept/Reject conflicts | |
Current-output/source checks, meaning flags and compiled layout auditions | |
Living numbers, evidence links, reviewer responses and portable records | |
typst.ts init, worker protocol, fonts, diagnostics normalization, preview/export | |
Provider types, capability probing, CORS/key caveats, local vs remote privacy | |
Drive Galley from Claude Code or Codex over MCP, on your own plan instead of an API key | |
Architecture Decision Records (ADRs) |
Quick start
The fastest path — run it with Docker (no toolchain needed):
docker compose up --build # → http://localhost:8080The Demo (offline) model lets you try the full agent loop with no provider or API key configured; open Settings to point at an OpenAI-compatible endpoint, Anthropic, or a local Ollama.
For development, use Node ≥ 20 and pnpm 9.15.9, as declared in
package.json:
pnpm install --frozen-lockfile
pnpm dev # runs @galley/webThe canonical checks run in Docker from the current source:
scripts/check-ci # lint, security/dependency audit, typechecks, PostgreSQL/unit tests, web build, Chromium
scripts/check-ci unit # iteration: lint, typechecks and unit tests
scripts/check-ci cross # Firefox/WebKit smoke for UI/compiler changesThe wrapper builds fresh images and collects artifacts in .ci-results by
default. See security scanning for additional scanners.
Self-hosting
docker compose up --build starts web + proxy + sync, with their published
ports bound to loopback. Open localhost:8080. The browser
uses proxy/collaboration only when configured; server compile stays off.
For a web-only process, run docker compose up --build web. The web app compiles
Typst in the browser by default, so it is complete on its own. See the
self-host guide and Kubernetes README.
Enabling server-side compile (opt-in). The heavier compile service isn't run
by default, so Settings → Compile → Server reports "Not configured." To wire it
up, use the ready-to-run overlay:
docker compose -f docker-compose.yml -f docker-compose.compile.yml \
--profile compile up --buildIt pre-sets GALLEY_COMPILE_URL=http://127.0.0.1:3001/compile (the
browser-reachable endpoint) so Server/Auto "just work"; the default
docker compose up leaves compile disabled. Details in
docs/self-host.md.
License
Galley is licensed under AGPL-3.0-only (see LICENSE): use,
modify, and self-host freely; if you offer a modified Galley to others over
a network, you must publish your modified source under the same license. The
"Galley" name and logo are protected separately by the
trademark policy — forks must rename. Contributions require
the CLA (see CONTRIBUTING).
The Typst compiler Galley builds on is Apache-2.0 (permissive — building on
it is fine); keep the name distinct (don't name anything "Typst") and ship
Typst's NOTICE if you ever redistribute its binary. See
docs/vision.md#licensing--branding.
Available Tools
8 toolscompileCompile the document for diagnosticsA
Type-checks the shared project and returns its diagnostics (errors/warnings + page count); never modifies the document. Uses the configured loopback compile service when one is set (--compile-url); otherwise falls back to the paired browser's live preview compiler. Call this after propose_files/propose_edit to confirm the change set type-checks before asking the human to Accept.
Inputs: project (required).
galley_pingPing the Galley MCP kernelB
Liveness check. Returns 'pong' with the kernel version.
Inputs: echo.
list_filesList the project's filesA
Lists the live (non-deleted) files of the shared project — exact path + size (UTF-8 bytes when sizeExact, else a cheap lower bound), deterministic order; duplicate-path conflicts are flagged per entry. BINARY files (images/PDFs) appear too, carrying a { kind:"binary", hash, mime } pointer descriptor with an exact sizeBytes — pass that path to read_file to get the pointer. Read-only: changes go through propose_edit / propose_files.
Inputs: project (required).
list_projectsList the projects this session can reachA
Returns the one project this kernel was started on, as { projectId: "current", mainFile }. Pass that projectId as project to the other tools.
Inputs: no named parameters.
project_contextQuery-relevant project contextA
Returns the most RELEVANT excerpts across ALL the project's live files for a query (lexical ranking over structural chunks), each with provenance: file path, 1-based line range, and Typst heading path. Budget-limited and read-only: files with duplicate-path conflicts or over the per-file cap are skipped (listed in skipped with a reason), and selectionTruncated reports when relevant chunks did not fit the budget. Use read_file for a complete file.
Inputs: query (required), project (required), budget.
propose_editPropose an edit to one file (published for review)A
Applies search/replace edits to a scratch copy of ONE existing text file and publishes the result as a proposal. It never edits the document directly: the change is published for review — if this project has agent auto-accept armed it may apply automatically (the response says status "applied"), otherwise it awaits a human Accept in Galley. Inspect the returned status to know what happened. Each search must match the file's current text exactly once; failures come back as structured data (status: "edit_failed") — refine and retry. To create, rename or delete files, or to change several at once, use propose_files.
Inputs: path (required), edits (required), project (required), request (required).
propose_filesPropose a multi-file change (published for review)A
Proposes a change set across MULTIPLE files as ONE atomic proposal — create new files, edit existing ones, rename/move them (rename also moves into a folder), or delete them (e.g. add chapters/intro.typ and #include it from main.typ). It never changes the project directly: the set is published for review — if this project has agent auto-accept armed it may apply automatically (the response says status "applied"), otherwise it awaits a human Accept in Galley. Inspect the returned status to know what happened; the whole set lands all-or-nothing. For edit ops each search must match that file's current text exactly once; failures come back as structured data — refine and retry. Delete is a recoverable soft-delete. Paths must be safe in-tree project paths (leading slash, no traversal, not under /.galley). For binary files you may either inline the bytes (create-binary, base64) or, when the source already lives on the machine running the Galley kernel, reference it by ABSOLUTE local path (create-binary-path) so no base64 transfer is needed — both publish the same content-addressed pointer. A single proposal is capped at 32 ops (with aggregate size limits); to change more files, split the work across multiple sequential propose_files calls — each is reviewed and lands independently (there is no import-group transaction spanning proposals).
Inputs: ops (required), project (required), request (required).
read_fileRead a project file by pathA
Returns the live replicated text of any project file by EXACT path (as listed by list_files — no normalization, no globbing). Read-only. Files over 2097152 UTF-8 bytes are refused with an error, never truncated. A BINARY file (image/PDF) returns structured metadata { kind: "binary", path, hash, size, mime } instead of text — its bytes are not available through this tool.
Inputs: path (required), project (required).
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 operation: listing, reading, ranked search, single-file proposals, multi-file proposals, compilation, and liveness. The only mild overlap is propose_edit vs. propose_files, since a single-file edit could arguably go through either, but the descriptions explicitly route create/rename/delete/multi-file work to propose_files. read_file vs. project_context is also well delimited (exact path full text vs. budgeted ranked excerpts).
Most tools follow a clean verb_noun snake_case pattern (list_files, list_projects, read_file, propose_edit, propose_files). The deviations — project_context (noun phrase, no verb), compile (bare verb), and galley_ping (namespaced noun) — are readable and easy to remember, but break the otherwise uniform convention.
Eight tools is well within the sweet spot and every tool earns its place: read/list/search for inspection, two proposal paths distinguished by scope, compile for verification, and a ping for liveness. Nothing feels redundant or missing at the structural level.
The agent-side lifecycle is nearly complete: discover files, read, search, propose changes (single and atomic multi-file), and type-check. Small gaps remain — there is no way to list or inspect pending proposals after the fact, no accept/withdraw operation, and binary bytes cannot be retrieved (read_file only returns a pointer descriptor).
Maintenance
Related MCP Connectors
MCP server for Product Management
Related MCP Servers
- -
- -
- AGPL 3.0
- MIT