visualtorch-mcp
Renders PyTorch neural network architecture diagrams using VisualTorch, supporting multiple styles and customizable options.
README
<div align="center"> <h1>🔥 VisualTorch MCP 🔥</h1> </div>
MCP server for rendering PyTorch architecture diagrams with VisualTorch.
Documentation surfaced by this MCP points to the upstream VisualTorch docs in
willyfh/visualtorch/docs. The MCP does
not maintain a separate API guide.
The rendering styles are the upstream VisualTorch styles documented here:
The MCP accepts layered as an alias for flow to tolerate older VisualTorch releases and docs
that used the layered naming.
Install
python -m venv .venv
.\.venv\Scripts\python -m pip install -U pip
.\.venv\Scripts\python -m pip install -e ".[render]"
The render extra installs VisualTorch from willyfh/visualtorch so the newer flow and
render(...) APIs are available. If you already manage VisualTorch separately, install this MCP
with pip install -e . instead.
MCP config
Use the console script after installing in your environment:
{
"mcpServers": {
"visualtorch": {
"command": "visualtorch-mcp"
}
}
}
Or call the module through a specific Python interpreter:
{
"mcpServers": {
"visualtorch": {
"command": "D:\\Florent\\Desktop\\visualtorch-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "visualtorch_mcp.server"]
}
}
}
Tools
visualize_model
Renders a model and returns the output file path plus image metadata.
Arguments:
source: Python source code that defines the model and imports its dependencies.input_shape: shape including batch dimension, for example[1, 3, 224, 224]. For multi-input models, pass one shape per positional input, for example[[1, 3, 224, 224], [1, 10]].style:graph,flow,layered, orlenet.model_expression: expression evaluated aftersourceruns. Defaults tomodel; useNet()orbuild_model()when the source defines a class/factory.output_path: optional absolute or relative image path. Defaults to a generated PNG invisualtorch_outputs.options: VisualTorch render options such as{"palette": "dracula", "show_dimension": true}.workdir: optional working directory used while executing the model source.timeout_seconds: render subprocess timeout.
Example tool payload:
{
"source": "import torch\nfrom torch import nn\nmodel = nn.Sequential(nn.Conv2d(3, 8, 3, padding=1), nn.ReLU(), nn.Flatten(), nn.Linear(8 * 16 * 16, 10))",
"input_shape": [1, 3, 16, 16],
"style": "graph",
"options": {
"show_dimension": true,
"palette": "okabe_ito"
}
}
visualtorch_reference
Returns upstream VisualTorch documentation links for the requested style, including the GitHub docs source and Read the Docs page. Style aliases listed by this tool are MCP aliases, not separate VisualTorch documentation.
Development
python -m pip install -e ".[test]"
pytest
The render worker executes supplied Python source in a subprocess with a timeout. Treat it as a local developer tool: it intentionally runs model code so it can instantiate arbitrary PyTorch models, but the subprocess boundary prevents a render exception from crashing the MCP server.
Citation
If this MCP helps you use VisualTorch in research or published work, cite VisualTorch:
Hendria, W. F., & Gavrikov, P. (2024). VisualTorch: Streamlining visualization for PyTorch neural network architectures. Journal of Open Source Software, 9(102), 6678. https://doi.org/10.21105/joss.06678
@article{hendria2024visualtorch,
author = {Hendria, Willy Fitra and Gavrikov, Paul},
title = {VisualTorch: Streamlining Visualization for PyTorch Neural Network Architectures},
journal = {Journal of Open Source Software},
year = {2024},
volume = {9},
number = {102},
pages = {6678},
doi = {10.21105/joss.06678},
url = {https://doi.org/10.21105/joss.06678}
}
License
This MCP server is released under the MIT License. VisualTorch is also released under the MIT License by Paul Gavrikov and Willy Fitra Hendria; see the upstream VisualTorch 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.