JT

johannesbrandenburger/typst-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

187 stars 20 forks 质量 67 趋势 0MIT

johannesbrandenburger/typst-mcp 是从 https://github.com/johannesbrandenburger/typst-mcp. 导入的 MCP 服务器候选。

概览

johannesbrandenburger/typst-mcp 是从 https://github.com/johannesbrandenburger/typst-mcp. 导入的 MCP 服务器候选。

概述(AI 翻译)

Typst MCP 服务器是一个 MCP(模型上下文协议)实现,帮助 AI 模型与基于标记的排版系统 Typst 交互。该服务器提供 LaTeX 与 Typst 之间的转换工具,验证 Typst 语法,并从 Typst 代码生成图像。

可用工具

⚠️ 目前所有功能都以tools实现,因为光标和VS Code还无法处理其他原语。

服务器提供以下工具:

  1. list_docs_chapters():列出Typst文档中的所有章节。
  • 让LLM了解文档并选择章节阅读。
  • LLM应根据当前任务选择相关章节阅读。
  1. get_docs_chapter(route):检索Typst文档中的特定章节。
  • 基于LLM选择的章节,该工具检索章节内容。
  • 也可作为get_docs_chapters(routes: list),一次检索多个章节。
  1. latex_snippet_to_typst(latex_snippet):使用 Pandoc 将 LaTeX 代码转换为 Typst。
  • LLM在编写LaTeX方面比Typst更强,因此该工具帮助将LaTeX代码转换为Typst。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Typst MCP Server

Typst MCP Server is an MCP (Model Context Protocol) implementation that helps AI models interact with Typst, a markup-based typesetting system. The server provides tools for converting between LaTeX and Typst, validating Typst syntax, and generating images from Typst code.

Available Tools

⚠️ Currently all the functionality is implemented as tools, because Cursor and VS Code are not able to handle the other primitives yet.

The server provides the following tools:

  1. list_docs_chapters(): Lists all chapters in the Typst documentation.

    • Lets the LLM get an overview of the documentation and select a chapter to read.
    • The LLM should select the relevant chapter to read based on the task at hand.
  2. get_docs_chapter(route): Retrieves a specific chapter from the Typst documentation.

    • Based on the chapter selected by the LLM, this tool retrieves the content of the chapter.
    • Also available as get_docs_chapters(routes: list) for retrieving multiple chapters at once.
  3. latex_snippet_to_typst(latex_snippet): Converts LaTeX code to Typst using Pandoc.

    • LLMs are better at writing LaTeX than Typst, so this tool helps convert LaTeX code to Typst.
    • Also available as latex_snippets_to_typst(latex_snippets: list) for converting multiple LaTeX snippets at once.
  4. check_if_snippet_is_valid_typst_syntax(typst_snippet): Validates Typst code.

    • Before sending Typst code to the user, the LLM should check if the code is valid.
    • Also available as check_if_snippets_are_valid_typst_syntax(typst_snippets: list) for validating multiple Typst snippets at once.
  5. typst_to_image(typst_snippet): Renders Typst code to a PNG image.

    • Before sending complex Typst illustrations to the user, the LLM should render the code to an image and check if it looks correct.
    • Only relevant for multi modal models.

Getting Started

  • Clone this repository

    • git clone https://github.com/johannesbrandenburger/typst-mcp.git
  • Clone the typst repository

    • git clone https://github.com/typst/typst.git
  • Run the docs generation in the typst repository

    • cargo run --package typst-docs -- --assets-dir ../typst-mcp/typst-docs --out-file ../typst-mcp/typst-docs/main.json
      • Make sure to adjust the path to your local clone of the typst-mcp repository
      • This will generate the main.json and the assets in the typst-docs folder
  • Install required dependencies: uv sync (install uv if not already installed)

  • Install Typst

Running the Server

Local Installation

Execute the server script:

python server.py

Or install it in Claude Desktop with MCP:

mcp install server.py

Or use the new agent mode in VS Code:

在 GitHub 查看完整 README

安装

docker run --rm -i ghcr.io/johannesbrandenburger/typst-mcp:latest
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "typst": { "command": "docker", "args": [ "run", "--rm", "-i", "ghcr.io/johannesbrandenburger/typst-mcp:latest" ] } } }