Generates static PNG diagrams and animated GIF reveals of PyTorch neural network architectures using flow, graph, or LeNet styles.
Also known as willyfh/visualtorch
- Stars
- 351
- Tools
- —
- Downloads, 30 days
- 1,355
- Latest version
- 1.4.1
- Last commit
- Nov 14, 2026
- License
- MIT
What is VisualTorch MCP?
VisualTorch generates static PNG diagrams and animated GIF reveals of PyTorch neural network architectures using flow, graph, or LeNet styles.
Summary generated from the project's README
About VisualTorch MCP server
Creating visual representations of neural network architectures from PyTorch source code is what VisualTorch enables for machine learning researchers and developers. By using a stdio MCP server, users can generate static PNG diagrams or animated GIF reveals that show a model being built layer by layer. The tool supports three distinct visual styles: flow, graph, and LeNet.
This server operates locally via a client-neutral stdio connection and requires no specific plugins or extensions to work with your AI client. To get started, you install the package using pip with the mcp extra. The system works by tracing a real forward pass of the model to build the architecture, which means it can visualize both Sequential and custom PyTorch models. It provides structured output metadata and handles subprocess timeouts to ensure reliable diagram generation.
What you can do with it
- 1Produce animated model revealsAnimate the construction of a neural network one layer at a time in a GIF format.
- 2Visualize custom PyTorch modelsTurn complex custom model code into a readable graph or flow diagram.
Written from the project's README. Every use case is checked against a quote from it.
How to install VisualTorch MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall VisualTorch MCP in Claude Code
$ claude mcp add visualtorch -- uvx visualtorchInstall VisualTorch MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"visualtorch": {
"command": "uvx",
"args": [
"visualtorch"
]
}
}
}Install VisualTorch MCP in VS Code
.vscode/mcp.json
{
"servers": {
"visualtorch": {
"type": "stdio",
"command": "uvx",
"args": [
"visualtorch"
]
}
}
}Install VisualTorch MCP in VS Code CLI
$ code --add-mcp '{"name":"visualtorch","type":"stdio","command":"uvx","args":["visualtorch"]}'Install VisualTorch MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"visualtorch": {
"command": "uvx",
"args": [
"visualtorch"
]
}
}
}Install VisualTorch MCP in Codex
$ codex mcp add visualtorch -- uvx visualtorchInstall VisualTorch MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.visualtorch] command = "uvx" args = ["visualtorch"]
Install VisualTorch MCP in Gemini CLI
$ gemini mcp add -s user visualtorch uvx -- visualtorchInstall VisualTorch MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"visualtorch": {
"command": "uvx",
"args": [
"visualtorch"
]
}
}
}Automated checks
Ran Nov 13, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachablePass
- Open source license (OSI)Pass
- Commit or release in the last yearPass
- Package name not close to a popular packagePass
- Remote endpoint uses HTTPSNot checked
- Destructive tools are labelledNot checked
- No hidden instructions to the modelPass
- No critical advisory in the package or its dependenciesPass
README
View on GitHubVisualTorch aims to help visualize Torch-based neural network architectures. It currently supports generating flow-style, graph-style, and LeNet-style architectures for PyTorch Sequential and Custom models. Its original visual styles were inspired by visualkeras, pytorchviz, pytorch-summary, and torchview; since then, it has grown its own unified tracing backend and architecture-handling logic well beyond its origins.
Note: 1.0+ is a major release with breaking API changes, but with significantly better features and algorithms - upgrading is recommended. For the old API, use 0.2.5 or older.
Limitation: VisualTorch traces a real forward pass to build the diagram, which has an inherent
limitation shared by any tracing-based approach (not a bug, and not fixable without full symbolic
execution): models with data-dependent control flow (e.g. a branch only taken if a tensor
value crosses some threshold) only show whichever branch the traced dummy input happened to take.
Separately, a layer that returns multiple meaningful output tensors (e.g. a custom multi-task
head, or nn.LSTM's (output, (h_n, c_n))) still has its node's size based on only its first
tensor; with show_dimension=True, every output tensor's shape is shown in the label, not just
the first. Downstream connections are correct either way. Contributions are welcome!

Animated Reveal
Every style can also render as an animated GIF, revealing the model one layer/column at a time,
via visualtorch.animate(model, input_shape, style=...) - see it in action for
flow,
graph, and
lenet styles.

Documentation
Online documentation is available at visualtorch.readthedocs.io.
The docs include usage examples, API references, and other useful information.
Installation
See the Installation page.
MCP integration
VisualTorch includes an optional, client-neutral stdio MCP server for generating static PNG
diagrams and animated GIF reveals from PyTorch model source. It exposes capability discovery,
structured output metadata, documentation resources, subprocess timeouts, and all three canonical
styles (graph, flow, and lenet). Install it with pip install "visualtorch[mcp]" and see the
MCP integration guide
for the tool schemas, generic stdio configuration, examples, and trusted-code security boundary.
No client-specific plugin or extension is required.
Used in Research
VisualTorch has been used in published research, including works published in Nature, IEEE, and MDPI.
See the Research Showcase page for the full list.
Used VisualTorch in your research, built something with it, or found a paper that cites it? Tell us about it or open a pull request to add it directly - we'd love to hear.
Examples
See the Usage Examples page.
Contributing
Please feel free to send a pull request to contribute to this project by following this guideline.
Releases
See GOVERNANCE.md for release methodology and cadence, and the PyPI release history for past releases.
License
This poject is available as open source under the terms of the MIT License.
Originally, this project was based on the visualkeras (under the MIT license), with additional modifications inspired by pytorchviz, pytorch-summary, and torchview, all of which are also licensed under the MIT license.
Citation
Please cite this project in your publications if it helps your research.
Note: the paper below describes VisualTorch as of its publication date (2024). The project has since been substantially refactored, including breaking API changes (see the documentation for the current API) - the DOI always resolves to what was actually reviewed and published.
@article{Hendria2024,
doi = {10.21105/joss.06678},
url = {https://doi.org/10.21105/joss.06678},
year = {2024},
publisher = {The Open Journal},
volume = {9},
number = {102},
pages = {6678},
author = {Willy Fitra Hendria and Paul Gavrikov},
title = {VisualTorch: Streamlining Visualization for PyTorch Neural Network Architectures},
journal = {Journal of Open Source Software}
}
Star History
VisualTorch MCP questions
How do I add VisualTorch MCP to Claude Code?
Run claude mcp add visualtorch -- uvx visualtorch in your terminal. Add --scope user to make it available in every project.
How do I add VisualTorch MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
What styles of architecture diagrams can I generate?
VisualTorch supports three canonical styles: graph, flow, and lenet.
Can I create animations of my model architecture?
Yes, every style can be rendered as an animated GIF that reveals the model one layer or column at a time.
What is the limitation regarding data-dependent control flow?
Because VisualTorch traces a real forward pass, models with branches that depend on specific tensor values will only show the branch taken by the dummy input used during tracing.
How do I install the MCP server component?
You can install the MCP integration by using the command pip install "visualtorch[mcp]".