
Tensorcad
io.github.Filip-Pajalic由 GitHub 帳號 Filip-Pajalic 發布v0.1.21更新於 Oct 25, 2026
Design transformer LLM architectures and report their parameters, FLOPs, memory and cost
概覽
一個本機 MCP 伺服器,讓助理在訓練前設計 Transformer 語言模型,並估算其參數量、FLOPs、記憶體、吞吐量與成本。
- 可以做什麼
- 建立、開啟、列出與儲存設計,包括內建參考架構和從 Hugging Face 設定匯入,並支援檢查點、還原以及設計之間的結構與數值差異比較。逐區塊檢視設計、搜尋區塊目錄,並以批次操作進行編輯,例如新增節點、設定參數或符號、連接埠與重新命名,同時帶版本檢查。依設計規則驗證設計並取得修正提示。分析參數量、FLOPs、KV 快取、記憶體、吞吐量、成本和 Chinchilla 數據,並規劃如何在叢集上拆分訓練。將設計縮放到指定參數預算,並產生 PyTorch 模組與設定程式碼。
- 適用情境
- 適合在撰寫任何訓練程式碼之前草擬或修改 Transformer 架構,並了解其規模、運算量、記憶體和成本影響;也適合判斷某個設計能否在現有硬體上訓練。
- 執行需求
- 透過 stdio 在本機執行,通常使用 npx 呼叫 npm 套件。npx 方式需要 Node.js;Claude Desktop 也可改為安裝打包好的擴充功能。選用環境變數 TENSORCAD_ROOT 指定掃描設計檔案的目錄,預設為工作目錄。未宣告身分驗證。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Tensorcad,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@tensor-cad/mcp
An MCP server that lets an assistant design transformer language models and find out what they would cost, before anyone writes a training script.
It wraps @tensor-cad/engine, the analysis compiled from Go to WebAssembly: a typed block graph, symbolic shape inference, a design-rule check, the parameter/FLOPs/memory/cost model, and a PyTorch emitter. The server is headless — it works on .tensorcad.json files and the built-in reference architectures, with no editor running.
Built on the official TypeScript SDK v2 (@modelcontextprotocol/server 2.0.0), served over stdio.
Install
Claude Code
Add --scope project to write a committed .mcp.json for everyone on the repo. Resources then surface as @tensorcad:tensorcad://... mentions and prompts as /mcp__tensorcad__design_model.
Cursor
.cursor/mcp.json in the project, or ~/.cursor/mcp.json for every project:
Cursor keeps a limited number of tools active across all servers, which is why this one ships eighteen rather than forty.
Claude Desktop, in one click
Download tensorcad.mcpb from a release and open it. Claude Desktop installs it
as an extension and asks once for a folder to keep designs in.
The bundle is the server built for Node — which Claude Desktop ships and this
repository does not use — with the WebAssembly engine beside it. bun run build:mcpb builds one and starts it under Node before it is done, because the
two things that have broken it were both differences between Bun and Node rather
than anything in the server.
Claude Desktop, by hand
claude_desktop_config.json (Settings, Developer, Edit Config):
Any client
mcp.example.json is the repo-relative development form: bun packages/mcp/src/stdio.ts, run from the repository root.
TENSORCAD_ROOT sets the directory tensorcad_list_designs scans for .tensorcad.json files and that relative paths resolve against. It defaults to the process working directory.
Tools
Eighteen, all namespaced tensorcad_. Every one declares an inputSchema and an outputSchema and returns structuredContent alongside a readable text mirror; reads are annotated readOnlyHint and idempotentHint, and the two that overwrite something are annotated destructiveHint.
Five that answer questions the others cannot
analyze says what a design costs; it does not say why. explain takes one
path and answers that — the parameters as written and as evaluated, the shape on
every port, the share of the model's weights and compute — without the agent
reading the whole document to work it out.
diff is the other half of editing. An agent that has just applied four
operations can ask what they moved, structurally and numerically, against the
design it started from. plan answers the question that decides whether any of
it matters: would this train on the machines available, and how would it have to
be split.
scale and import_hf both produce a design rather than a report, and both save
it in the session, so the result can be analysed, diffed and generated from like
any other. That is why the store gained adopt: create builds a design from a
preset or from nothing, and these arrive whole.
Handles, not sessions
tensorcad_new_design and tensorcad_open_design mint a design_id; everything else takes it as an argument. That is what the 2026-07-28 revision asks for — cross-call state travels as an explicit handle rather than as connection state — and it means a client can restart the server mid-conversation without losing the thread of which design is meant.
Each design carries a revision that increments on every change. Pass expected_revision to tensorcad_apply_ops and a concurrent edit becomes a clear error naming the current revision, instead of a silent overwrite.
One patch tool, not thirty setters
tensorcad_apply_ops takes a list of operations and applies them in order to a copy. The first rejected operation aborts the batch and the design is left exactly as it was, so a half-applied edit is never observable.
A path is slash-separated (layers/block), and endpoints are blockId:port local to their own graph. Most designs are parameterised by symbols — L layers, D width, H heads, Hkv key/value heads, dh head dimension, F feed-forward width, V vocabulary — so set_symbol is usually the right edit rather than touching individual blocks.
Resources
The templated ones support argument completion, and the design and catalog templates enumerate their instances, so a client can offer them without guessing an id.
Prompts
design_model (target parameter count, context length, family), review_design, scale_design, explain_costs.
A typical session
The live editor bridge
Start the server with TENSORCAD_BRIDGE=1 and a running TensorCAD editor attaches to it. The agent's edits appear on the canvas as it makes them, and the human's edits come back the other way.
Then open the editor (bun run --cwd packages/ui dev, or the desktop build). The status bar's rightmost cell says agent, and pressing it detaches.
What happens, in order: the editor finds the bridge, publishes the design on screen — so the agent works on that, not on a file that resembles it — and the agent sees it in tensorcad_list_designs. From then on tensorcad_apply_ops lands on the canvas, and what the human does lands in the agent's store, at which point the client is told through notifications/resources/updated that the design's resources moved. An edit that arrives from the agent goes onto the editor's undo stack, so the person watching can take it back.
There is no second document. An earlier design had a LiveStore beside the FileStore, both behind DocumentStore; that gives a design two homes and no rule for which one is right when they differ. The bridge observes the one store the tools already write to, and an editor's edit goes through the same apply a tool call does — same revision check, same undo log.
Off unless asked for. Without the environment variable the server opens no port and is exactly as headless as it was, which is what keeps it usable in CI.
Who can connect. It binds 127.0.0.1, so nothing off the machine reaches it. It refuses an upgrade whose Origin is not a localhost one, because the same-origin policy does not stop a page on the internet opening a WebSocket to your loopback address. And it requires a token, written to ~/.tensorcad/session.json with owner-only permissions and served to loopback callers of GET /session — a browser cannot read the file, which is the only reason that endpoint exists. Anything already running on this machine as you can read the file anyway; the token is not a defence against that and is not meant to be.
TENSORCAD_BRIDGE_PORT moves it off 7357. The editor probes that port and the three above it, which is also the range the bridge falls back through when one is taken.
Also deliberately absent: tensorcad_render_preview (a canvas image needs the editor) and tensorcad_run_script (a scripting escape hatch, which wants a sandbox and an opt-in environment variable before it is worth shipping). Both are in the research notes as future tools; leaving them out keeps the count where clients are happy.
Publishing
server.json beside this README is the MCP registry manifest:
the namespace (io.github.Filip-Pajalic/tensorcad, which matches mcpName in
package.json), the npm package it points at, and the one environment variable
the server reads. It is checked against the registry's own schema when it is
written and against package.json on every test run, because what drifts is not
the schema but the version in two files.
The namespace is spelled the way GitHub spells the account, capitals and all.
The registry grants a GitHub login io.github.<owner>/* in the owner's own
casing and compares case-sensitively, so a lowercase namespace is refused with
a 403 even though GitHub itself does not care
(registry#689).
A test holds the namespace to the repository URL.
The release workflow publishes it: after the npm job has uploaded the package
this points at, the registry job signs in with the workflow's own GitHub OIDC
token — no secret — and runs mcp-publisher publish. By hand, from this
directory:
Development
The contract tests connect with the SDK's own client over a real stdio pipe and validate every tool's structuredContent against the outputSchema that tool advertised, so the declared contract and the actual answer cannot drift apart.
來源:packages/mcp/README.md,提交 e187a4f
工具
0版本歷史
10- v0.1.21最新Sep 26, 2026
- v0.1.20Sep 26, 2026
- v0.1.19Sep 26, 2026
- v0.1.18Sep 26, 2026
- v0.1.17Sep 25, 2026
- v0.1.16Sep 25, 2026
- v0.1.13Sep 25, 2026
- v0.1.12Sep 24, 2026
- v0.1.9Sep 24, 2026
- v0.1.8Sep 23, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。