Back to MCP directory
publicPublicdnsLocal runtime

latex-mathml-mcp-server

一个基于MCP协议的LaTeX数学公式转MathML服务器,提供工具和资源两种访问方式。

article

README

🚀 LaTeX 到 MathML MCP 服务器

本项目是一个使用 Model Context Protocol (MCP) 的服务器,可将 LaTeX 数学表达式转换为 MathML 格式,为数学表达式的处理提供了便捷的解决方案。此 README.md 文件由 DeepSeek V3 编写。

🚀 快速开始

本服务器能将 LaTeX 数学表达式转换为 MathML 格式,支持工具转换和资源访问两种方式,且基于标准 MCP 协议实现,便于集成。下面为你介绍启动服务器的步骤:

# 克隆此仓库
git clone https://github.com/HappyAny/latex-mathml-mcp-server.git
cd latex-mathml-mcp-server

# 安装依赖项
npm install mathjax-node
npm install @modelcontextprotocol/sdk

# 启动服务器
node index.js

服务器启动后将通过 stdio 传输监听 MCP 客户端连接。

✨ 主要特性

  • 格式转换:将 LaTeX 数学表达式转换为 MathML。
  • 两种方式:提供工具转换和资源访问两种方式。
  • 便于集成:标准 MCP 协议实现,便于集成。
  • 轻量快速:使用 MathJax - node 实现轻量级快速转换。

📦 安装指南

克隆仓库

git clone https://github.com/HappyAny/latex-mathml-mcp-server.git
cd latex-mathml-mcp-server

安装依赖

npm install mathjax-node
npm install @modelcontextprotocol/sdk

💻 使用示例

启动服务器

node index.js

可用服务

工具转换

  • 工具名称latex2mathml
  • 输入:LaTeX 字符串
  • 输出:MathML 字符串

资源访问

  • 资源 URI 模式mathml://{latex_expression}
  • 返回:LaTeX 表达式的 MathML 表示

📚 详细文档

客户端集成

要从 MCP 客户端连接到此服务器,请在客户端设置中添加以下配置:

{
    "mcpServers": {
        "latex-mathml-server": {
            "isActive": true,
            "command": "node",
            "args": [
                "path_to_your_server/index.js"
            ]
        }
    }
}

请将 path_to_your_server/index.js 替换为您实际的服务器脚本路径。

API 详情

工具:latex2mathml

请求格式

{
    "latex": "your_LaTeX_expression"
}

示例请求

{
    "latex": "E = mc^2"
}

响应格式

{
    "content": [
        {
            "type": "text",
            "text": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">...</math>"
        }
    ]
}

资源:mathml://{id}

使用以下 URI 模式访问数学表达式:

mathml://E%20%3D%20mc%5E2

⚠️ 重要提示:LaTeX 表达式应在资源 URI 中进行 URL 编码。

🔧 技术细节

依赖项

  • @modelcontextprotocol/sdk:MCP 服务器 SDK
  • mathjax-node:LaTeX 到 MathML 转换
  • zod:输入验证

构建

这是一个 Node.js 项目。只需克隆仓库并按照安装部分安装依赖项即可。

📄 许可证

本项目采用 MIT 许可证。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client