bt11-dev-mcp
# bt11-dev-mcp
Built for **Bittensor Global Hackathon, Track 2**.
A local migration and testing toolkit for Bittensor subnet developers moving
from SDK v9/v10 to **11.3.7**. Find legacy calls, look up pinned replacements
inside an editor, and validate a working subnet fixture against an official
Docker node. The scanner and catalog work offline after installation.
```mermaid
flowchart LR
Agent["IDE agent via MCP stdio"] --> Tools["Shared Python tools"]
CLI["bt11 CLI"] --> Tools
Tools --> Wheel["Pinned Bittensor SDK and migration rules"]
Tools --> Docker["Official subtensor-localnet"]
Tools --> Scaffold["Miner, validator, intent and tests"]
Bench["Paired benchmark"] --> AgentTools["MCP lookup results"]
AgentTools --> Model["OpenAI-compatible backend"]
```
## Install and try
Use Python 3.11–3.14 on macOS or Linux. Docker is needed for the chain fixture.
The checkout directory is the working directory for all commands below.
```sh
uv venv --python 3.12
source .venv/bin/activate
uv pip install -e '.[test]'
bt11 scan examples/legacy_subnet.py
bt11 rule write:set_weights
bt11 lookup SetWeights
pytest -q
```
With standard Python tooling, use `python3 -m venv .venv`, activate it,
then run `python -m pip install -e '.[test]'`. You can also run from a checkout
using `uvx --from . bt11 scan examples/legacy_subnet.py`.
`bt11 scan PATH --check` exits 1 for migration findings and 2 for incomplete
scans. The report includes file, line, UTF-8 byte column, rule, and replacement.
The 64 rules cover aliased imports, known SDK instances and common `self` fields,
legacy constructor and Shield keywords, and literal CLI flags in simple shell
and Python subprocess calls. Dynamic imports, cross-file dataflow, complex
shell expressions and runtime behavior require review. The scanner never
imports the target project. Its catalog loads operation schemas and intent
signatures from the installed wheel. For example, the pinned Python executor
uses `shielded=`, and `SetWeights` takes separate UID and weight lists.
For code scanning, run from the repository root:
```sh
bt11 scan . --format sarif > bt11.sarif
```
SARIF includes repository-relative paths, line locations and migration guidance.
Add `--check` when findings or incomplete coverage should fail the check.
[GitHub SARIF reference](https://docs.github.com/en/code-security/reference/code-scanning/sarif-files/sarif-support)
## Connect an editor
**Codex**
```sh
codex mcp add bt11 --env "BT11_WORKSPACE=$PWD" -- "$PWD/.venv/bin/bt11-dev-mcp"
```
**Claude Code**
```sh
claude mcp add --transport stdio bt11 --env "BT11_WORKSPACE=$PWD" -- "$PWD/.venv/bin/bt11-dev-mcp"
```
**Cursor**. Add this entry in `.cursor/mcp.json` in the project containing the
installed checkout. For a different workspace, set `command` to the absolute
path of the installed executable. [Cursor MCP configuration](https://cursor.com/docs/mcp)
```json
{
"mcpServers": {
"bt11": {
"type": "stdio",
"command": "${workspaceFolder}/.venv/bin/bt11-dev-mcp",
"env": {"BT11_WORKSPACE": "${workspaceFolder}"}
}
}
}
```
Try this prompt with an agent in the checkout.
> Use scan_legacy_bt on examples/legacy_subnet.py. Look up write:set_weights and
> the SetWeights API. Show the repaired chain calls and explain the metagraph
> result shape using the pinned SDK. Leave the legacy fixture available for comparison.
The server exposes `scan_legacy_bt`, `lookup_migration_rule`, `lookup_v11_api`,
`generate_v11_scaffold`, `localnet_up`, `localnet_seed_subnet`,
`localnet_inspect_metagraph`, and `localnet_reset`. Supply an absolute path for
scans when the editor launches the server from a different directory. Workspace
writes require `BT11_WORKSPACE`. Docker mutations over MCP additionally require
`BT11_MCP_LOCALNET_WRITE=1`. Seed and reset also take `confirm: true`. Use the
CLI for long Docker operations if your MCP client has a shorter timeout.
## Demo on a disposable localnet
Watch the [2:45 demo](https://github.com/imfeng/bt1-dev-mcp/releases/download/v0.1.0/bt1-demo.mp4) ([repository copy](demo/bt1-demo.mp4)), or reproduce the migration fixture,
worker scoring and transaction preview in one run after installation.
```sh
python demo/walkthrough.py verify
```
The walkthrough creates and cleans up its own disposable chain. It scans
the paired [v10 example](examples/legacy_subnet.py) and
[v11 example](examples/migrated_subnet.py), then calls the migrated
validator against the localnet. These commands show the individual steps.
```sh
bt11 localnet up
bt11 localnet seed
bt11 scaffold .runtime/demo
```
The seed output supplies **NETUID**, **MINER_HOTKEY**, **MINER_UID**, and
**WALLET_PATH**. Substitute these values in the rest of the demo. Leave the
miner running in one terminal and run the other commands in a second terminal.
```sh
bt11 localnet inspect NETUID
cd .runtime/demo
python -m pytest -q
python miner.py --netuid NETUID --hotkey MINER_HOTKEY
```
```sh
cd .runtime/demo
python validator.py --netuid NETUID --miner-hotkey MINER_HOTKEY
python intent.py --netuid NETUID --uid MINER_UID --wallet-path WALLET_PATH
```
The validator locates the miner in the metagraph and scores its localhost HTTP
answer. The weights example previews a typed intent without signing. This is a
fixture for exercising chain integration and app scoring. It uses localhost HTTP transport. Validator permits, emissions and production
networking are separate runtime concerns.
The node is the official `ghcr.io/raofoundation/subtensor-localnet:devnet` image.
Each workspace uses a separate Docker bridge to isolate the image's local peer
discovery, and publishes websocket port 9944 to loopback port 19944. To change
the host port, pass `--port` immediately after `localnet` and use the reported
endpoint in the scaffold. Use `bt11 localnet reset --yes` to discard the managed
chain, then `bt11 localnet up --real-blocks` for 12-second blocks. The seed
timeout defaults to 180 seconds with fast blocks and 600 seconds with real
blocks. Use `--timeout` to override it. The rolling image digest used for this
prototype on 2026-12-01 was
`sha256:90eaa14cfa40ce0d5cf383ee8377acc91defdaf6b5d3982a7db1cf04148ffae8`.
[Official localnet guide](https://www.bittensor.com/docs/guides/local-development)
Seeding uses dev Alice to fund disposable owner, validator and miner wallets.
It activates the subnet after the runtime's delay and verifies each UID in the
metagraph. On a managed fixture with a zero collateral lock share, it submits
the generated burn-only registration call directly, avoiding an observed Shield
carrier expiry on fast blocks. When the lock share is nonzero it uses the SDK
`BurnedRegister` intent with its required Shield routing. The seed tool targets
only the workspace-owned Docker node. If seeding stops, inspect `steps.jsonl`
under the local state directory. A completed seed returns the existing receipt.
An incomplete seed is fenced from replay until the fixture is reset. Wallets
remain in the ignored local state directory after reset, for inspection.
[BurnedRegister](https://www.bittensor.com/docs/tx/burned-register) · [Collateral policy](https://www.bittensor.com/docs/query/collateral-policy)
### Test with Docker or simnet
```sh
BT11_RUN_LOCALNET=1 pytest -q
uv pip install 'bittensor-simnet @ git+https://github.com/sontrh/simnet@9ebb92cb41e8d11b3b69e90a37fa2379ac0b8c82'
pytest -q tests/test_simnet.py
```
The Docker integration checks fixture creation, seeding, metagraph, generated
miner and validator, weights preview, and real-block startup. The optional
simnet test injects its substrate into the same generated SDK helper for a
registration lookup. Coverage depends on simnet's runtime implementation.
For example, the tested commit does not provide the SDK's `SubnetState` map.
[simnet repository](https://github.com/sontrh/simnet)
## Benchmark
With the disposable fixture already seeded, set `OPENAI_BASE_URL` to an
OpenAI-compatible API base ending in `/v1`. Supply a key through
`BT11_API_KEY` or `OPENAI_API_KEY` if the backend requires one.
```sh
bt11 benchmark --model MODEL_ID --localnet --concurrency 2 --max-tokens 512 \
--output .runtime/benchmark.json
```
The same 28 prompts run at temperature 0 on a single backend in paired,
alternating order. One arm receives the task alone and the other receives
migration and catalog responses fetched from the actual MCP server over stdio.
The harness selects the tool queries in advance. It scores expression syntax
and compares parsed ASTs to a fixed set of accepted forms. For nine read
cases, it also verifies the matching reference operation against the Docker
fixture. The harness uses parsed syntax and trusted read operations only.
This measures catalog grounding on this corpus and model.
| 2026-12-01 oMLX, `deepseek-v41-abliterated` | Task only | With MCP lookups |
| --- | ---: | ---: |
| Compiles as a Python expression | 24/28 | 28/28 |
| Meets the pinned API contract | 1/28 | 27/28 |
| Meets a contract backed by a live localnet read | 0/9 | 9/9 |
| Request errors | 0 | 0 |
The transcript carries the corpus hash, rubric version, parameters, answers
and scores. Rubric v2 accepts both implicit and explicit references to the
wallet’s default root-registration hotkey. AST equivalence remains limited
to vetted forms. [Rubric v2 run](evidence/omlx-rubric-v2.json) ·
[Original run](evidence/omlx-2026-12-01.json)
## Sources and disclosure
The legacy test snippets were authored for this entry using the SDK 10.3.1
wheel's `bittensor/core/subtensor.py` signatures. The v11 wheel's runtime
catalog, namespace stubs and executor were checked against the official
migration docs. The wheel is authoritative when its callable surface differs
from the live docs. [SDK 10.3.1](https://pypi.org/project/bittensor/10.3.1/) ·
[SDK 11.3.7](https://pypi.org/project/bittensor/11.3.7/) ·
[Migration guide](https://www.bittensor.com/docs/migration) ·
[SDK guide](https://www.bittensor.com/docs/sdk) ·
[Claude Code MCP guide](https://code.claude.com/docs/en/mcp)
This entry started as a new repository on 2026-12-01 during the event.
It builds on Bittensor SDK, the official localnet image and the Python MCP SDK.
The benchmark uses an existing local inference service. Optional simnet
compatibility is tested against third-party code. The work described above uses those existing dependencies. [HackQuest event](https://www.hackquest.io/hackathons/2026-Bittensor-Global-Hackathon)
## License
[MIT License](LICENSE) © 2026 Abner Huang.
TDQS
Scored across 8 tools
The localnet_* family splits cleanly into up/reset/seed/inspect with distinct actions and prerequisites, and scaffold vs scan target clearly different phases of work. The only mild overlap is between lookup_migration_rule and lookup_v11_api, both read-only lookups that differ by resource but could be confused at a glance.
All names are snake_case and verb-led, with the localnet_* prefix forming a coherent group for lifecycle operations. The remaining four tools embed the domain token mid-name (generate_v11_scaffold, lookup_v11_api, scan_legacy_bt), which is slightly less uniform but still readable and predictable.
Eight tools is well-scoped for a dev-environment server: each covers a distinct lifecycle step (scaffold, bring up, seed, inspect, reset, look up rules/APIs, scan legacy code) with no filler. Nothing appears redundant or missing at the count level.
The surface covers the main workflow end-to-end: scaffold generation, localnet lifecycle (up/seed/inspect/reset), documentation/migration lookup, and legacy scanning. Minor gaps exist around graceful shutdown or log inspection of the localnet (only a destructive reset), which agents could work around.