MCP server wrapping TeXicode CLI for LaTeX-formatted terminal output
Project description
MCP TeXicode Server
A Model Context Protocol (MCP) server that provides LaTeX to Unicode art rendering capabilities using TeXicode.
Built with the chuk-mcp-server framework for zero-configuration deployment.
Features
- ๐ render_latex: Convert LaTeX expressions to beautiful Unicode art
- ๐ render_markdown: Process markdown files with embedded LaTeX expressions
- ๐ check_texicode_version: Verify TeXicode installation
- ๐ Resources: Example LaTeX expressions and server configuration
- โ๏ธ Flexible Configuration: CLI args, environment variables, or defaults
Demo
Here's example of what this project can do. First, configure the MCP server with your agentic coding tool of choice, eg. IBM Bob, Claude Code, Codex, etc. and make sure mcp-texicode appears in the mcp servers list.
Send a prompt like the following example.
Prompt:
What are your Top 10 favorite extremely complex mathematical equations (using LaTex and texicode tools for formatting)?
Output:
Here are my Top 10 favorite extremely complex mathematical equations, beautifully rendered using TeXicode:
1. Einstein Field Equations (General Relativity)
1 1 8ฯ๐บ
2 ๐
-โถโโด๐
๐ +ฮ๐ =โถโโโโด๐
3 ฮผฮฝ 2 ฮผฮฝ ฮผฮฝ ๐โด ฮผฮฝ
2. Navier-Stokes Equations (Fluid Dynamics)
1 โ โ๐ฏ โ
2 ฯโโถโโโด+๐ฏโ
โ๐ฏโ=-โ๐+ฮผโยฒ๐ฏ+๐
3 โ โ๐ก โ
3. Riemann Zeta Function (Analytic Number Theory)
1 โ
2 โฐโโด 1 โฐโโฐ 1
3 ฮถ(๐ )=โโธ โถโโโด= โ โ โถโโโโโโด, โ(๐ )>1
4 โธโโด ๐หข โธ โธ 1-๐โปหข
5 โฟโผยน ๐ prime
4. Schrรถdinger Equation (Quantum Mechanics)
1 โ โก โยฒ โค
2 ๐โโถโโโดฮจ(๐ซ,๐ก)=โข-โถโโโดโยฒ+๐(๐ซ,๐ก)โฅฮจ(๐ซ,๐ก)
3 โ๐ก โฃ 2๐ โฆ
5. Cauchy-Riemann Equations (Complex Analysis)
1 โ๐ข โ๐ฃ โ๐ข โ๐ฃ
2 โถโโโด=โถโโโด, โถโโโด=-โถโโโด
3 โ๐ฅ โ๐ฆ โ๐ฆ โ๐ฅ
6. Yang-Mills Equations (Gauge Theory)
1 ฮผฮฝ ฮฝ
2 ๐ท ๐น =๐ฝ , ๐น =โ ๐ด -โ ๐ด -๐๐[๐ด ,๐ด ]
3 ฮผ ฮผฮฝ ฮผ ฮฝ ฮฝ ฮผ ฮผ ฮฝ
7. Atiyah-Singer Index Theorem (Differential Geometry)
1 โ
2 ind(๐ท)=โ ๐ดฬ(๐๐)โงch(๐ธ)
3 โก
4 แดน
8. Ramanujan's Master Theorem
1 โ โ
2 โ โฐโโด ฯ(๐)(-๐ฅ)โฟ
3 โ ๐ฅหขโปยนโโธ โถโโโโโโโโโโด๐๐ฅ=ฮ(๐ )ฯ(-๐ )
4 โกโ โธโโด ๐!
5 โฟโผโฐ
9. Gauss-Bonnet Theorem (Differential Geometry)
1 โ โ
2 โ ๐พ ๐๐ด+โ ๐ ๐๐ =2ฯฯ(๐)
3 โก โก แต
4 แดน โ๐
10. Dirac Equation (Relativistic Quantum Mechanics)
1 ฮผ
2 (๐ฮณ โ -๐)ฯ=0
3 ฮผ
Each equation is now rendered in beautiful Unicode mathematical notation using the TeXicode rendering engine!
Installation
Prerequisites
-
Install TeXicode CLI (required):
# Using pipx (recommended) pipx install TeXicode # Or using pip pip install TeXicode
-
Install mcp-texicode:
# Clone the repository git clone https://github.com/yourusername/mcp-texicode.git cd mcp-texicode # Install dependencies pip install -e .
Configuration
The server supports multiple configuration methods (in order of precedence):
- Command-line arguments (highest priority)
- Environment variables
- Default values (lowest priority)
Command-Line Arguments
python -m mcp_texicode.server [OPTIONS]
Options:
--transport {stdio,http} Transport mode (default: stdio)
--host HOST Host for HTTP transport (default: 0.0.0.0)
--port PORT Port for HTTP transport (default: 8000)
--debug Enable debug mode (default: false)
--log-level {DEBUG,INFO,WARNING,ERROR}
Logging level (default: WARNING)
--no-escape-filters Disable ANSI escape sequence filtering (default: enabled)
-h, --help Show help message
Environment Variables
| Variable | Description | Default |
|---|---|---|
MCP_TRANSPORT |
Transport mode: stdio or http |
stdio |
MCP_HOST |
Host to bind to (HTTP only) | 0.0.0.0 |
MCP_PORT |
Port to bind to (HTTP only) | 8000 |
MCP_DEBUG |
Enable debug mode: true or false |
false |
MCP_LOG_LEVEL |
Logging level: DEBUG, INFO, WARNING, ERROR |
WARNING |
MCP_NO_ESCAPE_FILTERS |
Disable ANSI escape sequence filtering: true or false |
false |
Usage Examples
1. Default Configuration (stdio for Claude Desktop)
python -m mcp_texicode.server
This uses stdio transport, which is the standard for MCP clients like Claude Desktop.
2. HTTP Transport with Custom Port
python -m mcp_texicode.server --transport http --port 8080
Or using environment variables:
MCP_TRANSPORT=http MCP_PORT=8080 python -m mcp_texicode.server
3. Debug Mode
python -m mcp_texicode.server --debug --log-level DEBUG
Or using environment variables:
MCP_DEBUG=true MCP_LOG_LEVEL=DEBUG python -m mcp_texicode.server
4. Production HTTP Server
python -m mcp_texicode.server \
--transport http \
--host 0.0.0.0 \
--port 8000 \
--log-level WARNING
Claude Desktop Configuration
To use with Claude Desktop, add to your claude_desktop_config.json:
macOS
Location: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows
Location: %APPDATA%\Claude\claude_desktop_config.json
Configuration Examples
1. Using uv with Local Clone (Recommended for Development)
If you've cloned the repository locally and want to use uv for dependency management:
{
"mcpServers": {
"texicode": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-texicode",
"run",
"mcp-texicode"
]
}
}
}
Note: Replace /absolute/path/to/mcp-texicode with the actual path to your cloned repository.
Example paths:
- macOS/Linux:
"/Users/username/Code/mcp-texicode" - Windows:
"C:\\Users\\username\\Code\\mcp-texicode"
2. Using uv with Installed Package
If you've installed mcp-texicode via pip/uv:
{
"mcpServers": {
"texicode": {
"command": "uvx",
"args": ["mcp-texicode"]
}
}
}
3. Using Python Directly
{
"mcpServers": {
"texicode": {
"command": "python",
"args": ["-m", "mcp_texicode.server"]
}
}
}
4. With Custom Configuration (Environment Variables)
{
"mcpServers": {
"texicode": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-texicode",
"run",
"mcp-texicode"
],
"env": {
"MCP_TRANSPORT": "stdio",
"MCP_LOG_LEVEL": "INFO",
"MCP_DEBUG": "false"
}
}
}
}
5. With Custom Configuration (CLI Arguments)
{
"mcpServers": {
"texicode": {
"command": "python",
"args": [
"-m",
"mcp_texicode.server",
"--transport",
"stdio",
"--log-level",
"INFO"
]
}
}
}
6. Using Virtual Environment
If you have a specific virtual environment:
{
"mcpServers": {
"texicode": {
"command": "/absolute/path/to/venv/bin/python",
"args": ["-m", "mcp_texicode.server"]
}
}
}
Verifying Configuration
After updating your configuration:
- Restart Claude Desktop completely (quit and reopen)
- Check the MCP icon in Claude Desktop - it should show the texicode server
- Test a tool by asking Claude to render a LaTeX expression
Example prompt to test:
Can you render the quadratic formula using the texicode server?
Output Filtering
By default, the server filters ANSI escape sequences from TeXicode output to provide clean Unicode art. This is because the TeXicode CLI (txc) can output color formatting codes that may not be desired in all contexts.
Why Filtering?
- Without filtering:
txc -c "x^2"outputs 30 bytes including ANSI color codes:\x1b[38;5;232m\x1b[48;5;255mxยฒ\x1b[0m - With filtering (default): Same expression outputs clean 4 bytes:
xยฒ
Disabling Filters
If you want to preserve ANSI escape sequences (e.g., for color output in terminals that support it):
Using CLI argument:
python -m mcp_texicode.server --no-escape-filters
Using environment variable:
MCP_NO_ESCAPE_FILTERS=true python -m mcp_texicode.server
In Claude Desktop config:
{
"mcpServers": {
"texicode": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-texicode",
"run",
"mcp-texicode",
"--no-escape-filters"
]
}
}
}
Available Tools
render_latex
Render a LaTeX expression to Unicode art.
Parameters:
expression(string, required): LaTeX expression to rendercolor(boolean, optional): Enable color output (default: false)normal_font(boolean, optional): Use normal font instead of serif (default: false)
Example:
# In Claude Desktop or MCP client
render_latex(expression="\\frac{a}{b}")
render_latex(expression="\\int_0^\\infty e^{-x^2} dx", color=True)
render_markdown
Process markdown content with embedded LaTeX expressions.
Parameters:
content(string, required): Markdown content with LaTeX expressionscolor(boolean, optional): Enable color output (default: false)normal_font(boolean, optional): Use normal font instead of serif (default: false)
Example:
render_markdown(content="The formula is $E = mc^2$")
check_texicode_version
Check if TeXicode is installed and working.
Returns: Dictionary with installation status and version information.
Available Resources
texicode://examples
Get example LaTeX expressions that can be rendered.
texicode://config
Get server configuration and capabilities.
LaTeX Examples
Basic Expressions
# Fractions
\frac{a}{b}
# Exponents and subscripts
x^2, a_i
# Greek letters
\alpha, \beta, \gamma, \pi
# Integrals
\int_0^\infty e^{-x^2} dx
# Summations
\sum_{i=1}^n i^2
# Square roots
\sqrt{x^2 + y^2}
Famous Formulas
# Quadratic formula
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
# Euler's identity
e^{i\pi} + 1 = 0
# Gaussian integral
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
Project Structure
mcp-texicode/
โโโ src/
โ โโโ mcp_texicode/
โ โโโ __init__.py
โ โโโ server.py # Main server implementation
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
Transport Modes
stdio (Default)
- Use case: MCP clients like Claude Desktop
- Protocol: JSON-RPC over stdin/stdout
- Configuration: No network configuration needed
- Best for: Desktop applications, CLI tools
http
- Use case: Web services, remote access, testing
- Protocol: HTTP with Server-Sent Events (SSE)
- Configuration: Requires host and port
- Best for: Web applications, microservices, debugging
Troubleshooting
TeXicode Not Found
If you get an error about TeXicode not being installed:
# Install TeXicode
pipx install TeXicode
# Verify installation
txc "x^2"
Port Already in Use (HTTP mode)
If the port is already in use, specify a different port:
python -m mcp_texicode.server --transport http --port 8080
Debug Mode
Enable debug mode to see detailed logs:
python -m mcp_texicode.server --debug --log-level DEBUG
License
MIT License - see LICENSE file for details.
Credits
- Built with chuk-mcp-server
- Uses TeXicode for LaTeX rendering
- Implements the Model Context Protocol
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_texicode-0.1.0.tar.gz.
File metadata
- Download URL: mcp_texicode-0.1.0.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
615cd7c34d36fa168bc8b6beef757436bde21fb44de5b147ab17c54ad04c2181
|
|
| MD5 |
85bf99d1df4b76d71fe58b18e33535bd
|
|
| BLAKE2b-256 |
afc9af78ff4e77635a8a0aec81c95078af22883f63ad03249015bc7462f5b044
|
File details
Details for the file mcp_texicode-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_texicode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7c5622951cc5b45ad3bbd64497380b94152bf765fda35d1ed0965dca35d0c78
|
|
| MD5 |
9b4b770d8b9863cdad627d93773fd42e
|
|
| BLAKE2b-256 |
c6240a61809edd6c224a8934dd224187b0f31f8673802837558022c7fcefb776
|