Skip to content

Commit eed955d

Browse files
committed
fix(wiki export): clearer error messages; pre-check for LaTeX engine
Two small UX fixes driven by a user who read the previous error as 'mactex-no-gui is specifically required' when in fact basictex is enough. 1. Missing-pandoc message — separates the primary blocker (pandoc) from the PDF-only secondary (LaTeX engine), names basictex as an acceptable cheap option, mentions tlmgr for on-demand packages. 2. New fast-fail when pandoc is present but no LaTeX engine on PATH (tries pdflatex, xelatex, lualatex, tectonic). Previously pandoc would run and fail with a noisy stderr; now users get a single actionable line.
1 parent eea6a81 commit eed955d

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

mcp_server/handlers/wiki_export.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,33 @@ async def handler(args: dict[str, Any] | None = None) -> dict[str, Any]:
174174
if not pandoc:
175175
return {
176176
"error": (
177-
"pandoc not installed on this host. Install with "
178-
"`brew install pandoc` (macOS) or `apt install pandoc` "
179-
"(Linux). For PDF export also install a TeX engine: "
180-
"`brew install --cask mactex-no-gui` or "
181-
"`apt install texlive-xetex`."
177+
"pandoc is not installed — install it first and the "
178+
"four export formats (HTML, TEX, DOCX, PDF) will all "
179+
"work. Install: `brew install pandoc` (macOS) or "
180+
"`apt install pandoc` (Linux). "
181+
"For PDF specifically you ALSO need a LaTeX engine, "
182+
"but basictex / mactex / texlive-xetex are all "
183+
"acceptable — any one of them supplies `pdflatex`. "
184+
"basictex alone is enough for simple documents; "
185+
"missing packages can be added later with `tlmgr`."
182186
)
183187
}
188+
# Fast, actionable check specific to PDF — if pandoc is present
189+
# but no LaTeX engine is, the pandoc process would fail with a
190+
# noisy stderr. Pre-check and surface a clean message instead.
191+
if fmt == "pdf":
192+
engines = ("pdflatex", "xelatex", "lualatex", "tectonic")
193+
if not any(shutil.which(e) for e in engines):
194+
return {
195+
"error": (
196+
"pandoc is installed but no LaTeX engine was found "
197+
"on PATH (tried: " + ", ".join(engines) + "). "
198+
"Install one: `brew install --cask basictex` "
199+
"(smallest; includes pdflatex) or "
200+
"`brew install --cask mactex-no-gui` (full) on "
201+
"macOS; `apt install texlive-xetex` on Linux."
202+
)
203+
}
184204

185205
from mcp_server.infrastructure.config import METHODOLOGY_DIR
186206

0 commit comments

Comments
 (0)