Get the FREE Ultimate OpenClaw Setup Guide →

latex-mathml

A Model Context Protocol (MCP) server that converts LaTeX mathematical expressions to MathML format.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio happyany-latex-mathml-mcp-server node index.js

How to use

This MCP server provides two ways to convert LaTeX expressions to MathML using the MCP protocol. First, you can use the tool-based conversion by calling the latex2mathml tool with a JSON payload that includes a LaTeX string; the server responds with a MathML string wrapped in the MCP response format. Second, you can access predefined MathML representations via a resource URI using the mathml:// pattern, where the LaTeX expression is URL-encoded in the URI. The server is built with MathJax-node for fast, lightweight conversion and integrates with the standard MCP SDK for easy client integration.

To connect from an MCP client, start the server (for example with node index.js) and configure your client to point to the latex-mathml-server MCP endpoint. You can then invoke the latex2mathml tool by sending a request like { "tool": "latex2mathml", "latex": "E = mc^2" } and receive a response containing the corresponding MathML. For resource-based access, request a URI such as mathml://E%20%3D%20mc%5E2 to retrieve the MathML for the encoded LaTeX expression.

How to install

Prerequisites:

  • Node.js (and npm) installed on your system
  • Access to the project repository for latex-mathml-mcp-server

Installation steps:

  1. Clone the repository: git clone https://github.com/HappyAny/latex-mathml-mcp-server.git cd latex-mathml-mcp-server

  2. Install dependencies: npm install npm install mathjax-node npm install @modelcontextprotocol/sdk

  3. Verify installation:

    • Ensure node is available: node -v
    • Ensure npm packages are installed: npm ls
  4. Run the server: node index.js

  5. Optional: run in the background or via a process manager (e.g., pm2) for production use.

Additional notes

Notes and tips:

  • The latex2mathml tool converts a given LaTeX string to MathML using MathJax-node.
  • The resource-based access uses the mathml:// URI pattern with a URL-encoded LaTeX expression, e.g., mathml://E%20%3D%20mc%5E2.
  • If you modify the path to the server script, update your MCP client configuration accordingly (e.g., replace index.js with the correct path).
  • Ensure dependencies are installed in the same project directory where the server runs.
  • Common issues: incorrect LaTeX syntax may cause conversion errors; always validate inputs before sending to the server.
  • Environment variables are not mandatory by default but can be added for advanced configuration (e.g., port, logging).

Related MCP Servers

Sponsor this space

Reach thousands of developers