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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。