VisualTorch — Claude Code MCP server: diagrams and setup
VisualTorch turns PyTorch model structure into architecture diagrams and animated GIFs. Use it when an agent needs to inspect a neural network visually.
claude mcp add visualtorch -- uvx visualtorchWhat VisualTorch does
VisualTorch is an MCP server for visualizing PyTorch models. It can render graph, flow, and lenet architecture styles, plus animated GIFs that reveal the model layer by layer or column by column. The server uses stdio and returns structured output metadata.
The project lists Python 3.10+ and PyTorch 2.0+ as requirements. Its MCP extras can be installed with visualtorch[mcp], while Claude Code connects through uvx. VisualTorch supports PyTorch Sequential and custom models. It traces a real forward pass, so data-dependent control flow is represented by the branch taken for the test input. Models with several meaningful output tensors still get node sizing from the first tensor, although show_dimension=True can show every output shape. That matters when the model relies on conditional paths or multi-output layers.
What it helps with
- render a PyTorch architecture diagram
- map layer connections in
graphstyle - generate a model view in
floworlenetstyle - create a GIF that reveals the architecture step by step
- inspect a custom model through a forward pass
Example prompts for the agent
- Use VisualTorch to render the PyTorch model from
model.pyingraphstyle and show tensor dimensions. - Generate an animated
flowGIF for this model with VisualTorch. - Render the same model in
graph,flow, andlenetstyles, then compare the diagrams.
How to install VisualTorch
Platform CLI
claude mcp add visualtorch -- uvx visualtorchuvx runs the command named after the package; if the README names another one, use uvx --from visualtorch <command>
Platform CLI
codex mcp add visualtorch -- uvx visualtorchuvx runs the command named after the package; if the README names another one, use uvx --from visualtorch <command>
Config file
{
"mcpServers": {
"visualtorch": {
"command": "uvx",
"args": [
"visualtorch"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from visualtorch <command>
Config file
{
"servers": {
"visualtorch": {
"type": "stdio",
"command": "uvx",
"args": [
"visualtorch"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from visualtorch <command>
Platform CLI
gemini mcp add visualtorch uvx visualtorchuvx runs the command named after the package; if the README names another one, use uvx --from visualtorch <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about VisualTorch
How do I install VisualTorch in Claude Code?
Run claude mcp add visualtorch -- uvx visualtorch.
What does VisualTorch do?
VisualTorch renders PyTorch architectures in graph, flow, and lenet styles, and can create animated GIFs that reveal the model progressively.
What tracing limits should I know about?
VisualTorch follows a real forward pass. A data-dependent branch is shown according to the test input, and a node with several outputs is sized from its first tensor.