Typst MCP 服务器是一个 MCP(模型上下文协议) 的实现,帮助 AI 模型与 Typst,一个基于标记的语言排版系统进行交互。该服务器提供了在 LaTeX 和 Typst 之间转换、验证 Typst 语法以及从 Typst 代码生成图像的工具。
⚠️ 目前所有功能都作为
tools实现,因为 Cursor 和 VS Code 尚无法处理其他原始功能。
服务器提供以下工具:
list_docs_chapters():列出 Typst 文档中的所有章节。
get_docs_chapter(route):从 Typst 文档中检索特定章节。
get_docs_chapters(routes: list) 来一次性检索多个章节。latex_snippet_to_typst(latex_snippet):使用 Pandoc 将 LaTeX 代码转换为 Typst。
latex_snippets_to_typst(latex_snippets: list) 来一次性转换多个 LaTeX 片段。check_if_snippet_is_valid_typst_syntax(typst_snippet):验证 Typst 代码。
check_if_snippets_are_valid_typst_syntax(typst_snippets: list) 来一次性验证多个 Typst 片段。typst_to_image(typst_snippet):将 Typst 代码渲染成 PNG 图像。
克隆此仓库
git clone https://github.com/johannesbrandenburger/typst-mcp.git克隆 typst 仓库
git clone https://github.com/typst/typst.git在 typst 仓库中运行文档生成
cargo run --package typst-docs -- --assets-dir ../typst-mcp/typst-docs --out-file ../typst-mcp/typst-docs/main.json
main.json 和 typst-docs 文件夹中的资源安装所需依赖项:uv sync(如果尚未安装,请安装 uv)
安装 Typst
执行服务器脚本:
python server.py
或在 Claude Desktop 中使用 MCP 安装它:
mcp install server.py
或在 VS Code 中使用新的代理模式:
⚠️ Typst 文档的架构不稳定,可能会随时更改。架构是从 typst 源代码生成的,不保证完整或正确。如果架构发生变化,需要相应地更新此仓库,以便文档功能再次正常工作。