Create MermaidJS diagrams effortlessly with a server, tools, and mmdc CLI integration
mcp-mermaidjs-server is an MCP (Model Context Protocol) server designed to facilitate the creation and visualization of MermaidJS diagrams within various AI applications. This server enables seamless integration between these applications and specific tools, enhancing their capabilities in generating, storing, and displaying complex diagram data. By leveraging the Model Context Protocol, this server ensures a standardized method for interaction with other MCP clients.
mcp-mermaidjs-server provides two primary functionalities: saving MermaidJS diagrams and visualizing them based on specific output formats and CSS styles. These features are crucial for developers looking to integrate dynamic, visually-rich diagramming capabilities into their AI applications without the need for complex coding.
The save-diagram
tool allows users to create a MermaidJS diagram by first defining it using an mmd (Mermaid Markdown) specification. This tool then saves this definition in a structured format, ready for later processing or sharing.
Once a diagram is saved via the save-diagram
tool, the visualize-diagram
tool can render it in various output formats, such as SVG, PNG, or PDF, using specified CSS styles to ensure the desired presentation. This flexibility makes mcp-mermaidjs-server ideal for generating and manipulating diagrams within AI workflows.
The mcp-mermaidjs-server operates by adhering to the Model Context Protocol (MCP), ensuring interoperability with various MCP clients such as Claude Desktop, Continue, Cursor, and others. This server uses the mmdc
MermaidJS CLI tool under the hood for rendering diagrams.
The core implementation involves starting the MCP server using specific command-line arguments:
mmdc
is located on your system.Example configuration for running the MCP server in different environments:
{
"mcp_mermaidjs_server": {
"command": "java",
"args": [
"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory",
"-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog",
"-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector",
"-Dlog4j2.configurationFile=log4j2-mcp.xml",
"-Dbabashka.json.provider=metosin/jsonista",
"-Dlogging.level=INFO",
"-Dmcp.vegalite.mmdc_executable=/Users/vedang/.local/share/nvm/v23.11.0/bin/mmdc",
"-cp", "/Users/vedang/repo-name/target/tech.unravel/mcp-mermaidjs-server-1.0.0.jar",
"tech.unravel.mcp-mermaidjs-server"
]
}
}
npx @modelcontextprotocol/inspector java -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Dlog4j2.configurationFile=log4j2-mcp.xml -Dbabashka.json.provider=metosin/jsonista -Dlogging.level=INFO -Dmcp.vegalite.mmdc_executable=/Users/vedang/.local/share/nvm/v23.11.0/bin/mmdc -cp /Users/vedang/repo-name/target/tech.unravel/mcp-mermaidjs-server-1.0.0.jar tech.unravel.mcp-mermaidjs-server
To build and run mcp-mermaidjs-server, follow these steps:
Clean and Build: Ensure the project is clean before building.
make clean && make build
Run the MCP Server: Use either of the provided configuration options to start the server.
MermaidJS diagrams can be used extensively in project management to represent workflows, timelines, and dependencies. For instance, a diagram could depict how tasks are interrelated and their scheduling within a project.
sequenceDiagram
loop everyday D-2 working days 16:00
ABCD->>DEE: [14:25] BEE (Calculation per TC until ACK becomes OK)
ABCD->>FGG: BEE (Calculation per TC until ACK becomes OK)
Note over ABCD,FGG: D-2 weekdays at 14:25
ABCD->>HII: Projected Authorisations to HII
Note over ABCD,HII: D-2 weekdays at 16:00
end
loop D-1 before deadline at 7:45
HII->>DEE: Submission
Note over HII,DEE: D-1 before deadline
HII->>FGG: Submission
Note over HII,FGG: D-1 before deadline
end
Using mcp-mermaidjs-server, real-time data flow visualizations can be created and updated within AI applications. This enhances understanding of complex systems by providing clear, interactive diagram representations.
mcp-mermaidjs-server is compatible with multiple MCP clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
mcp-mermaidjs-server is optimized for handling diagram-related tasks efficiently, ensuring low latency and high performance. The server handles requests quickly and accurately, making it suitable for real-time updates in dynamic environments.
Configuration of the mcp-mermaidjs-server involves setting up environment variables to control various aspects such as logging and server behavior. These configurations can be adjusted via the command-line arguments passed during startup:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Ensure that environment variables such as mcp.vegalite.mmdc_executable
are securely set and not exposed in logs or other public areas.
Q: Can mcp-mermaidjs-server be integrated with non-MCP clients? A: While primarily designed for MCP, it can be modified to work with non-MCP clients by adjusting the Protocol implementation and environment variables.
Q: How do I specify custom output formats for MermaidJS diagrams?
A: Use the visualize-diagram
tool along with specifying CSS styles to render MermaidJS diagrams in desired formats like SVG, PNG, or PDF.
Q: What happens if mmdc is not installed when running the server?
A: The MCP server will fail to start due to missing dependencies. Ensure that mmdc
is correctly installed and its path is set in the environment variables.
Q: How can I optimize performance for large diagrams? A: Optimize by increasing the heap size during JVM startup, enhancing the rendering process, and using caching mechanisms where appropriate.
Q: When will API key support be added? A: API key authentication is planned in future releases to enhance security and ensure access control.
Contributions are welcome! If you wish to contribute to the development of mcp-mermaidjs-server, please follow these guidelines:
For more resources and information about the MCP protocol and its ecosystem, visit:
This documentation provides a comprehensive overview of mcp-mermaidjs-server as an essential tool for developers looking to integrate MermaidJS diagrams into their AI applications using the Model Context Protocol.
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Python MCP client for testing servers avoid message limits and customize with API key
Discover easy deployment and management of MCP servers with Glutamate platform for Windows Linux Mac
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
Explore community contributions to MCP including clients, servers, and projects for seamless integration