mermaid-to-jpeg-mcp
A local MCP server for Cursor that converts Markdown files and Mermaid diagrams to JPEG images with configurable dimensions and quality.
README
Cursor MCP Server - Markdown to JPEG Converter
A local Model Context Protocol (MCP) server for Cursor that enables converting Markdown files to JPEG images. This server supports both regular markdown content and Mermaid diagrams.
Features
- Convert regular Markdown files to JPEG images
- Convert Mermaid diagrams to JPEG images
- Configurable image dimensions and quality
- Automatic detection of Mermaid diagram syntax
- Clean, styled output for regular markdown content
Prerequisites
Make sure you have the following installed:
- Node.js (v14 or later)
- npm or yarn
- ImageMagick (
brew install imagemagick) - Mermaid CLI (
npm install -g @mermaid-js/mermaid-cli)
Installation
- Clone or copy the project files to your desired location
- Install dependencies:
npm install
Usage
Standalone Script
You can use the standalone script to convert markdown files:
# Convert markdown to JPEG
node md-to-jpeg.js input.md [output.jpeg]
# Convert using the original mermaid-only script
node generate-diagram.js input.md [output.png]
MCP Server
The MCP server provides two tools:
- convert_md_to_jpeg: Convert any markdown file to JPEG
- convert_mermaid_to_jpeg: Convert Mermaid diagrams to JPEG
MCP Server Configuration
To use with Cursor, add the following to your MCP configuration:
{
"mcpServers": {
"markdown-to-jpeg": {
"command": "node",
"args": ["/path/to/your/cursor-mcp/server.js"],
"env": {}
}
}
}
Running the Server
Start the MCP server:
npm start
Or run directly:
node server.js
Tools Available
convert_md_to_jpeg
Convert a markdown file to JPEG image with customizable options.
Parameters:
input_file(required): Path to the input markdown fileoutput_file(optional): Path for the output JPEG filewidth(optional): Width of the output image (default: 1200)height(optional): Height of the output image (default: 800)quality(optional): JPEG quality 1-100 (default: 90)
convert_mermaid_to_jpeg
Convert a Mermaid diagram file to JPEG image.
Parameters:
input_file(required): Path to the input mermaid fileoutput_file(optional): Path for the output JPEG file
Example Usage
Regular Markdown
# My Document
This is a sample markdown document with:
- **Bold text**
- *Italic text*
- `Code snippets`
## Code Block
```javascript
function hello() {
console.log("Hello, world!");
}
This is a blockquote
### Mermaid Diagram
```markdown
```mermaid
graph TD
A[Start] --> B{Is it?}
B -->|Yes| C[OK]
C --> D[Rethink]
D --> B
B ---->|No| E[End]
## Supported Formats
- **Input**: Markdown (.md), Mermaid diagrams
- **Output**: JPEG (.jpeg, .jpg)
## Dependencies
- `@modelcontextprotocol/sdk`: MCP SDK for server implementation
- `puppeteer`: For rendering HTML to images
- `marked`: Markdown parsing
- `@mermaid-js/mermaid-cli`: Mermaid diagram generation
- `imagemagick`: Image format conversion
## Troubleshooting
### Common Issues
1. **"mmdc command not found"**: Install Mermaid CLI globally
```bash
npm install -g @mermaid-js/mermaid-cli
-
"convert command not found": Install ImageMagick
brew install imagemagick -
Puppeteer issues: Make sure Chrome/Chromium is installed and accessible
Testing
Test the conversion with a sample file:
npm test
Or create a test markdown file and run:
echo "# Test Document\n\nThis is a test." > test.md
node md-to-jpeg.js test.md
License
MIT License
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.