
Neuronscope
io.github.RudrenduPaul由 GitHub 帳號 RudrenduPaul 發布v0.1.5更新於 Oct 24, 2026
Traces which neurons and attention heads drive a language model's output via MCP tools.
概覽
本機 MCP 伺服器,用來追蹤語言模型中哪些注意力頭與 MLP 神經元影響了預測的下一個詞元,並回傳帶版本號的 JSON。
- 可以做什麼
- 對提示詞做追蹤,依 logit 歸因排序注意力頭、依活化強度排序 MLP 神經元,並給出預測的下一個詞元
- 匯出各層殘差流、MLP 神經元與注意力模式的活化統計摘要
- 對指定層的某個元件做零消融,回報預測詞元及其 logit 的變化
- 透過排序元件並逐一量測其單獨因果效應,產生盡力而為的電路草圖
- 回傳與命令列 --json 輸出相同結構的帶版本號 JSON,出錯時回傳結構化錯誤而非拋出例外
- 適用情境
- 適合讓助理以機制可解釋性的方式說明某個具體模型預測,或在不寫 TransformerLens 程式碼的情況下,對單一提示詞做快速、可腳本化的分析。它只是窄範圍的封裝,不能取代更深入的電路或 SAE 工具。
- 執行需求
- 以本機 stdio 程序執行,通常透過 uvx 從 neuronscope-cli 這個 PyPI 套件啟動(或使用 neuronscope mcp-server 子命令),需要安裝 mcp 額外相依。會引入 Python 與 PyTorch,首次執行會從 HuggingFace Hub 下載所選模型(gpt2 約 500MB)。未宣告任何 API 金鑰或環境變數;CUDA GPU 為選用,小模型在 CPU 上即可執行。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Neuronscope,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
NeuronScope
[NeuronScope - Traces LLM outputs to the neurons and heads that caused them | Product Hunt]
Ask a language model "why did you say that" and get back the actual attention heads and neurons responsible, as JSON, from the command line or from an agent over MCP.
Install
That gets you the neuronscope command. To install from source instead (for development or to
track main):
[!NOTE] The first run of any command downloads the requested model from the HuggingFace Hub (
gpt2is about 500MB) and prints two lines to stderr that are expected, not errors: a CPU-fallback notice if you don't have a CUDA GPU, and an unauthenticated-HF-Hub rate-limit notice. Neither one means anything broke.
Quickstart
Real output from this exact command (stderr trimmed to the two expected warnings mentioned above):
gpt2 predicts Tokyo correctly, and head L9H8 is the single biggest contributor to that
prediction. Add --json to get the machine-readable version of the same result:
What it does
NeuronScope is a CLI and MCP server built on top of TransformerLens. TransformerLens does the actual model loading, hooking, and activation math; NeuronScope adds a stable CLI, a versioned JSON schema, and an MCP server around it, so a script or an agent can ask "which components drove this output" without writing TransformerLens code directly.
trace: runs a prompt through the model and ranks attention heads by direct logit attribution to the predicted token, and MLP neurons by activation magnitude at the final prompt position.activations: dumps shape, mean, std, min/max, and the max-activating sequence position for every layer's residual stream, MLP neuron activations, and attention pattern.patch: zero-ablates one component (resid_pre,resid_mid,resid_post,attn_out,mlp_out, ormlp_post) at a given layer and reports how the predicted token and its logit changed.circuit: a best-effort automated circuit sketch. Ranks candidate heads/neurons by logit attribution, then measures each one's individual causal effect via single-component ablation. This is not full path-patching with clean/corrupted prompt pairs and does not capture interaction effects between components. The--jsonoutput says so explicitly in itsmethodfield.- Every command supports
--jsonfor aschema_version-stamped document instead of a table, and the same four operations are exposed as MCP tools returning the identical shape via.model_dump(), so a CLI call and an MCP tool call produce the same document for the same input. - Model support is whatever
transformer_lens.HookedTransformer.from_pretrainedsupports. Installingneuronscope-clitoday pulls TransformerLens 3.6.0, which supports 249 pretrained checkpoints and aliases (OFFICIAL_MODEL_NAMES), covering GPT-2, Pythia, Llama, Gemma, Qwen, and more. Small models likegpt2run comfortably on CPU.
NeuronScope does not replace TransformerLens, nnsight, SAELens, Anthropic's circuit-tracer, or Neuronpedia. It wraps TransformerLens for one narrower job: fast, scriptable, agent-callable component tracing on a single prompt. It leaves deeper mechanistic work (SAE training, transcoder-based circuit graphs, hosted feature browsing) to those tools.
CLI reference
Every command takes MODEL (any name HookedTransformer.from_pretrained accepts, for
example gpt2 or EleutherAI/pythia-70m) and PROMPT as positional arguments.
Global: neuronscope --version, neuronscope <command> --help. Exit codes: 0 success,
1 a runtime error (prompt too long for the model's context window, --layer out of range,
etc.), 2 a Click usage error (bad flags), 3 an unsupported model name.
MCP Server
NeuronScope ships a Model Context Protocol server so an AI agent (Claude, Cursor, or any MCP-compatible client) can trace, inspect, ablate, and sketch circuits directly, without a human invoking the CLI by hand.
Install the extra:
Add it to your MCP client's config (for Claude Desktop, claude_desktop_config.json):
The server exposes four tools, trace, activations, patch, and circuit, each returning
the identical pydantic-model-shaped JSON the CLI's --json flag prints, via .model_dump(), so
an agent calling this server and a script calling the CLI get the same document for the same
input. A real trace call and its response:
Errors never raise across the tool boundary: every handler catches its exceptions and returns a
structured ErrorResponse dict instead, so a calling agent always gets a parseable result.
[!WARNING] NeuronScope caps model size (2B parameters by default,
NEURONSCOPE_MAX_MODEL_PARAMS) and how many models can load at once (1 by default,NEURONSCOPE_MAX_CONCURRENT_LOADS), but puts no timeout on model loading or forward passes. If you expose this MCP server somewhere an untrusted agent can call it, still put a resource limit around the process (a cgroup,ulimit, or a container memory/CPU cap) as defense in depth rather than relying on these in-process caps alone.
Transport is stdio, so there is nothing to host: the MCP client spawns the server as a local
subprocess. Source: neuronscope/mcp_server.py.
- Claude Code reads this from a project-level
.mcp.jsonin your repo root, or you can add it withclaude mcp add neuronscope -- neuronscope-mcp. - Claude Desktop reads this from its
claude_desktop_config.json(~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS,%APPDATA%\Claude\claude_desktop_config.jsonon Windows), under the same"mcpServers"key. - The
neuronscope mcp-serverCLI subcommand still works as a local, non-uvxalternative that runs the same server over stdio from an existing install.
How it compares
All five of these are real, actively maintained projects doing different jobs. This table compares CLI/JSON-agent-output surface and model coverage, not depth of interpretability research, where TransformerLens, nnsight, SAELens, circuit-tracer, and Neuronpedia are all more mature than NeuronScope. Star counts, release info, and last-push dates below were pulled from each project's GitHub API on 2026-08-03 and will drift over time; check the repos directly for current numbers.
The honest differentiation is narrow: NeuronScope is the only one of these with a CLI, a native MCP server, and a versioned JSON schema together in one package, and it's model-agnostic across whatever TransformerLens supports rather than pinned to a fixed transcoder allowlist like circuit-tracer. It is not more capable, more mature, or more widely used than any of these projects.
What is NeuronScope and why does it exist
TransformerLens gives you a Python API for loading a model and running hooked forward passes. That's the right interface for a research notebook. It's the wrong interface for a script that needs a subprocess call and a JSON document back, or for an agent that needs a tool it can call over MCP. NeuronScope exists to be that second interface: the same underlying computation, wrapped so a CLI invocation or an MCP tool call gets back a schema-versioned document instead of a Python object graph.
FAQ
Is this a replacement for TransformerLens, nnsight, SAELens, circuit-tracer, or Neuronpedia? No. NeuronScope is built directly on TransformerLens and does not do anything TransformerLens itself can't already do at a lower level. It doesn't train SAEs (SAELens), do full path-patching circuit discovery with transcoders (circuit-tracer), give you a Python-native tracing context manager for arbitrary PyTorch models (nnsight), or host a browsable feature database (Neuronpedia). It's a CLI and MCP wrapper around one slice of TransformerLens's functionality.
What models are supported?
Anything transformer_lens.HookedTransformer.from_pretrained supports, which today is 249
checkpoints and aliases spanning GPT-2, Pythia, Llama, Gemma, Qwen, and others. Run
python -c "from transformer_lens.loading_from_pretrained import OFFICIAL_MODEL_NAMES; print(len(OFFICIAL_MODEL_NAMES))"
in your own environment to get the exact count for your installed version, since
TransformerLens adds models over time.
Does it need a GPU?
No. Small models like gpt2 run fine on CPU; that's what the test suite and the quickstart
above run on. Larger models will be slow on CPU. NeuronScope does not auto-select Apple
Silicon's MPS backend even when available, because PyTorch's MPS backend can silently
produce incorrect values for some ops that this project's activation-patching math depends
on being exact. Pass device="mps" explicitly in your own code if you want it anyway.
Is it safe to expose the MCP server to an untrusted agent? Only with resource limits in place. See Known limitations below.
How is NeuronScope different from circuit-tracer, the other CLI tool in this list? circuit-tracer does deeper circuit analysis (full attribution graphs from trained transcoders) but only for a fixed allowlist of models: Gemma-2, Gemma-3, Llama-3.1/3.2, Qwen-3, and GPT-OSS. NeuronScope trades that depth for breadth: it works with any of TransformerLens's 249 supported checkpoints with no transcoder training step, and ships an MCP server so an agent can call it directly. The cost is that NeuronScope does single-component logit attribution and zero-ablation, not transcoder-based path patching.
Does the installed version always match what's on PyPI?
Run neuronscope --version after installing to check. pip install neuronscope-cli pulls
whatever release PyPI has published most recently; the code on this repo's main branch can
be ahead of that between releases. Installing from source (pip install -e .) always tracks
main exactly, including whatever hasn't been released yet.
What license is NeuronScope under, and can I use it commercially?
MIT. You can use, modify, and redistribute it in commercial and closed-source projects,
with attribution and the license notice kept intact. The dependencies it pulls in
(TransformerLens, PyTorch, the mcp package) carry their own licenses; check those
separately if you're redistributing a bundled product rather than just calling
neuronscope-cli as a dependency.
Known limitations
circuitis an approximation. It ranks components by logit attribution and measures each one's individual causal effect via single-component zero-ablation on one prompt. It does not do full path-patching with clean/corrupted prompt pairs, and it will not catch interaction effects between components. The--jsonoutput states this in itsmethodfield so a caller doesn't have to trust prose to know the caveat.- No timeout on model loading or forward passes. Once a request passes the resource
caps below, NeuronScope runs the load and the forward pass to completion with no
built-in wall-clock limit. If you run the MCP server somewhere an untrusted agent can
call it, put a resource limit around the process (a cgroup,
ulimit, or a container memory/CPU cap) as defense in depth. - Model size and load concurrency are capped, but only in-process.
neuronscope/core/limits.pyrejects a model overNEURONSCOPE_MAX_MODEL_PARAMS(2B parameters by default) before any weights are downloaded, and rejects a load onceNEURONSCOPE_MAX_CONCURRENT_LOADS(1 by default) other loads are already in flight, both with a structured error rather than a hang or a crash. The size check is best-effort: if a model's parameter count can't be determined (for example, fully offline with nothing cached yet), it fails open rather than blocking a legitimate request, so it's not a hard guarantee on its own -- pair it with a process-level resource limit for untrusted deployments. HookedTransformer.from_pretrainedis deprecated upstream. TransformerLens 3.6.0 emits aDeprecationWarningpointing atTransformerBridge.boot_transformersas the replacement. It still works today, and every command shown in this README ran on it, but NeuronScope's backend hasn't migrated yet. Tracked as an open item; migrating would be a change insideneuronscope/backends/transformer_lens.py, not a change to any CLI command or MCP tool signature.
Contributing
Issues and pull requests are welcome. See CONTRIBUTING.md for dev setup, where the code lives, and what a PR needs before it merges. Quick version:
CI runs the same suite on Python 3.10, 3.11, and 3.12 on every push and pull request against
main. The suite covers 87% of neuronscope/ (pytest --cov=neuronscope), with the MCP
server's less-exercised paths (specific error branches) the main gap.
License
MIT. See LICENSE.
來源:README.md,提交 7b36f97
工具
0版本歷史
1- v0.1.5最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分