hw-native-sys
A local MCP server for full-stack compiler development across the hw-native-sys workspace — combining repo operations with a curated knowledge layer so an agent can orient and act in a few calls.
Repo operations: list repos and health, ripgrep code search (
locations/context), git log/diff, read arbitrary files, list/explain/run named tasks and ad-hoc commands (NPU- or sim-Docker-routed per policy).Session bootstrap & routing:
bootstrap_session,route_task,list_task_types,list_knowledge_topics— one-call orientation with docs, rules, entrypoints, and verify tasks.Docs & knowledge:
read_doc(tier-labeled canonical/enriched/design/mcp-owned, section extraction),layer_guideper framework layer,find_entrypoints,list_skills/find_skill.Concepts & tracing:
explain_abstraction,search_abstractions,explain_pass,explain_scheduler,explain_task_queue,list_workloads,trace_in_stack,trace_contract.Status & tracking:
program_status,collective_status,search_tracker(GitHub issues/PRs),pr_watch(one-shot CI/review snapshot),summarize_profile.Verification & release:
verify_ladder(minimal tests + clang-tidy),generate_verify_handoff(NPU gate for humans),gate_pr_script(safe rebase→pre-commit→sim-tests→squash→push),find_generated_artifacts.Environment & self-audit:
ascend_env_check,knowledge_health(missing paths, stale docs, index coverage).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@hw-native-sys bootstrap a session for compiler work"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
hw-native-sys MCP server
A local Model Context Protocol (MCP) server for full-stack compiler development across the hw-native-sys workspace. It combines operations (git health, code search, running named tasks) with a knowledge layer (architecture docs, task routing, an abstraction index, pass pipeline info, cross-repo status) so an agent — or you — can get oriented in one or two calls instead of grepping five repos by hand. pypto-lib is the model layer and compiles through pypto. InCore kernels then lower pypto → PTOAS → pto-isa and run on simpler; orchestration goes pypto → simpler directly.
This doc is the full reference: setup, every tool/resource/prompt, the config files behind them, how the knowledge index is built and kept honest, and how to extend the server yourself.
Repositories it operates over
Repo | Role |
| Compiler framework: Python DSL → IR → passes → codegen |
| PTO assembler/optimizer: |
| Virtual tile ISA: C++ headers, CPU/NPU backends |
| simpler runtime: task graph execution on AICore/AICPU |
| Model zoo and golden validation harness |
| Enriched planning notes, retrospectives, cross-repo status (secondary tier — not canonical) |
| Top-level design/architecture proposals (design tier — non-canonical, forward-looking) |
| OSU-style PyTorch/HCCL bandwidth micro-benchmarks (NPU) |
| Umbrella: agent skills, runbooks, task-submit doc |
| Shared agent-skill plugins ( |
| Docker images and build scripts for the pypto stack (this server's sim images) |
| Collective benchmark harness (pypto vs simpler vs HCCL) |
| VS Code toolkit: chip swimlane viewer, task dependency graph, perf table over dfx outputs |
| Wiki clone: weekly project-changes log |
| This MCP server |
Related MCP server: devcontract
Setup
From a checkout of this repo, next to the sibling stack repos:
cd mcp-hw-native-sys
python3 -m venv .venv
source .venv/bin/activate
pip install -e .Requires Python ≥ 3.10, the mcp package (installed by the command above), and rg (ripgrep) on PATH for search_code. search_tracker, pr_watch, and the hw-native-sys-pr-watch CLI also need the GitHub CLI (gh) logged in to an account that can read the hw-native-sys org. The server does not pick a model. Cursor, VS Code, Claude Code, and Claude Desktop each choose Claude, GPT, Gemini, Grok, or whatever else that client offers; the tools and prompts are the same.
Workspace root resolution
The server needs to know where the sibling repos live. In order of precedence:
HW_NATIVE_SYS_ROOTenv var, if set.config/repos.json's"workspace_root"field. It is checked in as"..", resolved from this repo, so the parent directory that holds the sibling repos. That is the path a normal checkout uses.Fallback, only when
workspace_rootis empty:project_root().parents[1](the parent of that workspace directory, not the workspace itself).
You generally don't need to set HW_NATIVE_SYS_ROOT unless you're running the server from a copy that isn't in its usual place relative to the sibling repos.
Quick local run (stdio, manual)
source .venv/bin/activate
hw-native-sys-mcpHW_NATIVE_SYS_ROOT is optional. Set it only when this repo is not checked out as mcp-hw-native-sys/ inside the workspace that holds the sibling repos.
Clients
The process is a stdio MCP server. The command is .venv/bin/hw-native-sys-mcp, relative to this repo. ${workspaceFolder} below is the directory that contains both this repo and its siblings.
Cursor. Project file .cursor/mcp.json:
{
"mcpServers": {
"hw-native-sys-mcp": {
"command": "${workspaceFolder}/mcp-hw-native-sys/.venv/bin/hw-native-sys-mcp"
}
}
}After the command changes, enable the server once under Customize → MCPs. Prompts then show up in chat as /hw-native-sys-mcp/start_compiler_work, /hw-native-sys-mcp/start_ascend_work, /hw-native-sys-mcp/start_distributed_work, /hw-native-sys-mcp/start_npu_verify, /hw-native-sys-mcp/debug_codegen_work, and /hw-native-sys-mcp/finish_work.
VS Code. Workspace file .vscode/mcp.json:
{
"servers": {
"hw-native-sys": {
"type": "stdio",
"command": "${workspaceFolder}/mcp-hw-native-sys/.venv/bin/hw-native-sys-mcp"
}
}
}Claude Code. .mcp.json in the workspace root:
{
"mcpServers": {
"hw-native-sys": {
"command": "mcp-hw-native-sys/.venv/bin/hw-native-sys-mcp"
}
}
}Tools appear as mcp__hw-native-sys__<tool_name>.
Claude Desktop. Add a stdio server whose command is the absolute path to .venv/bin/hw-native-sys-mcp in your checkout. Desktop configs do not expand ${workspaceFolder}.
Recommended daily workflow
Call the
start_compiler_workprompt (orstart_distributed_work/start_ascend_work/start_npu_verifydepending on the task) — this gives you the exact next steps.Call
bootstrap_session(task_type=...)— one call returns route metadata (read_plan), repo health, and active-program hints together.Follow
read_plan: read canonical docs first, enriched docs second. Useread_doc(path, section=...)to pull a single markdown section out of a large note instead of the whole file.Call
layer_guide(layer)for the framework layer you are in (pypto,ptoas,pto-isa,simpler,pypto-lib). It returns that repo's docs, skills, and rules. Useexplain_pass/explain_abstraction(name, layer=...)/search_abstractions/trace_contract/trace_in_stackto pin down stack concepts before writing code. Passlayerwhen the same name exists in two layers (tmovin PTOAS vsTMOVin pto-isa).Call
program_statusfor the local plan dashboard, andsearch_trackerfor live open and merged GitHub issues and PRs. Callcollective_statusif the work touches collective communication ops.Implement.
Run
verify_ladder(changed_paths)to get the minimal verify set:suggested_tasks(pytest) plusstatic_checks— when a changed path is a C/C++ file in a C++ repo,static_checksis["clang-tidy"]and clang-tidy on the changed files is required before committing (see thetools/clang_tidy_workflowresource for the compile-db prerequisite and per-repo commands).Run
agent_verify_tasksviarun_task. Never rundeveloper_verify_tasks(NPU/hardware-gated) yourself — those are for the human developer.
Build & test policy (NPU-or-sim-Docker)
The server never builds/tests directly on a local repo unless NPUs are
reachable. Every heavy (build/test/package) task is routed on
npu-smi availability:
NPU reachable → the host
commandruns as configured (host builds allowed).No NPU →
run_taskre-routes the task into the repo's sim Docker image (mounted worktree + in-container install) and reports the redirect in the result'snote. Images:pypto3-hw-native-sys:sim(pypto/pto-isa),simpler-hw-native-sys:sim,pypto-lib-hw-native-sys:sim— built frompypto-docker/Dockerfile.*sim.ubuntu22.04.No NPU + image missing → the task is refused with the exact
docker buildcommand to create the image first.No sim image for the repo (e.g. PTOAS) → refused with guidance.
run_commandrefuses ad-hoc build/test commands (cmake/make/ninja/pip install/pytest/…) when no NPU is reachable; read-only commands are unaffected. Tasks whose command already runs in a container are markedsim_docker: trueand bypass routing.
See content/tools/sim_docker_workflow.md (MCP resource tools/sim_docker_workflow)
for the full loop, and pypto-3.0-notes/pr_plans/00-branch-and-pr-standards.md
§ Sim Docker for the canonical iteration loop.
Tools
Operations (mcp_hwnative_sys/server.py)
Tool | Purpose |
| Repos, paths, and architecture metadata |
| Branch, dirty state, ahead/behind upstream, last commit, |
| Ripgrep across one/many/all repos. |
| Named tasks configured for a repo (from |
| Run a named task in a repo, with |
| Ad-hoc shell command in a repo's root; destructive patterns ( |
| Show the exact command + metadata for one named task (repo-first: |
| Structured commit list (sha, author, date, message) for a repo |
|
|
| Read an arbitrary source file from a repo (paginated via |
| Single-call session bootstrap: route + |
| Generate a self-contained bash script for the PR gate (rebase → pre-commit → sim-Docker tests → squash → force-push). Validates preconditions but never executes git/docker itself |
Knowledge (mcp_hwnative_sys/knowledge.py and friends)
Tool | Purpose |
| All valid |
| Read-first docs (canonical + enriched), rules, entrypoints, matching skills, and verify tasks for a |
| Enumerate all task routes, MCP resources, notes topics, and bootstrap prompts in one call |
| Read a workspace doc with tier labeling ( |
| Docs, skills, and rules for one framework layer ( |
| Concept card for an IR node, pass, codegen stage, ISA instruction, PTOAS op, or Ascend hardware concept. Optional |
| Keyword search across the abstraction index. Optional |
| simpler scheduler level ( |
| pypto-lib model catalog from |
| Read-only |
| Read-only GitHub search of issues and PRs ( |
| Read-only one-shot PR snapshot: CI rollup, review decision, unresolved review threads, review summaries, conversation comments, and new-only deltas. Pass |
| Pass-pipeline card: order, phase, neighbors, verify tasks (from the |
| Structured open PRs, blockers, and plan cross-index from |
| Collective-comm feature parity status (merged/planned/gap) from the parity matrix in |
| Minimal suggested verify tasks for a list of changed file paths (longest-matching-prefix rules) |
| Locate generated-code artifacts across the workspace: pass dumps, |
| Inventory the agent-skill corpus per repo (pypto, pypto-lib, simpler, PTOAS, pto-isa, pypto-* plugins, pypto-tooling), read live from each SKILL.md |
| Match a task description against every repo's skill names/descriptions to find the right workflow (e.g. compare-codegen, generate-ir-trace, dfx-analyze) |
| Code entrypoints for a repo and optional sub-area |
| Locate a symbol or path in the |
| Enriched cross-layer trace: stack location + contract triangle + cross-layer verify tasks + active-PR links |
| Self-audit: missing paths, stale enriched docs (>30 days since |
| Read-only NPU/CANN/HCCL environment diagnosis (devices, |
| Markdown handoff for a human to run NPU verification. On queue hosts the commands are wrapped in |
| Summarize a |
MCP resources
Fixed URIs, read via an MCP resource client (or by finding the matching path via read_doc/list_knowledge_topics):
Prefix | Example URIs | Content |
|
| Multi-repo roles, compilation pipeline |
|
| pypto subsystem overviews |
|
| Sibling-repo overviews |
|
| Model zoo / harness layer |
|
| HCCL bandwidth benchmarking |
|
| Agent-facing rules and the task-routing index |
|
| Ascend hardware/platform reference |
|
| End-to-end worked examples |
|
| MCP-owned task workflows (sim-Docker loop, mandatory clang-tidy step, PR gate, PR test standards, PR watch) |
|
| Pipeline-wide map of generated-code inspection: per-stage artifact → flag/API → output path → inspection tool/skill |
| see notes topics below | Enriched notes (secondary tier) |
Doc tiers (returned by read_doc/route_task): canonical (sibling repo docs — authoritative) > enriched (pypto-3.0-notes — secondary, check last_verified) > design (pypto_top_level_documents — forward-looking proposals, non-canonical) > mcp-owned (content/ — this server's own decision-tree docs) > ephemeral (pr_plans/, pull_requests/ — living/scratch, refused by read_doc, use program_status/collective_status instead).
Notes topics (notes/{topic}, resource or read_doc)
abstractions_master, codegen_infrastructure, dependency_triangle, distributed_work_policy, host_collectives, kernel_orchestration, machine_hierarchy, moe, multi_level_runtime_ring, notes_simpler, pass_infrastructure, ptoas_abstractions, ptoisa_abstractions, pypto_abstractions, pypto_lib_attention, pypto_lib_building_blocks, pypto_lib_distributed_support, pypto_lib_models, pypto_lib_status, runtime_arch_index, runtime_async, runtime_design, serving_implementation_plan, sharded_tensor, simpler_abstractions, simpler_distributed_runtime_design, stack_availability, tensor_layout, tensor_valid_shape, tpush_tpop_isa_design
MCP prompts
Prompt | Params | Use when |
|
| General compiler work — any new session should start here or with one of the below |
|
| Collectives, L3 runtime, distributed codegen, large-scale inference |
|
| Ascend hardware architecture, performance tuning, HCCL |
| — | Developer-only: hand off to real-NPU container verification (agent must not run this itself — see the prompt body for the exact gate) |
| — | Closing loop: verify_ladder → agent_verify_tasks → clang-tidy (if C++ changed) → generate_verify_handoff for the NPU-gated remainder |
|
| Debug a compile/lowering/codegen bug by inspecting generated code at each pipeline stage (route → catalog → find artifacts → inspect → fix → verify) |
Each prompt returns a short markdown playbook naming the exact tool-call sequence for that kind of work.
Task types (route_task / bootstrap_session / list_task_types)
task_type | Covers |
| Any new session — multi-repo roles and compilation pipeline |
| New IR nodes, types, or structural changes |
| Pass pipeline additions or modifications |
| InCore codegen to |
| Orchestration codegen to simpler runtime C++ (AICPU path) |
| Debug by inspecting generated code across the pipeline: pass dumps, |
| Distributed ops, collectives, multi-rank |
| Composite collectives, ring vs. mesh algorithms |
| Host builtin collectives program (barrier, broadcast, reduce_scatter, allgather) |
| Distributed codegen backend |
|
|
| pypto-lib models, golden harness, inference paths |
| What building blocks/ops/models exist in pypto-lib and their distributed support |
| PTO assembler and optimizer ( |
| Virtual tile ISA headers and backends |
|
|
| Model zoo, kernels, golden validation harness |
| Compile/runtime profiling for training/inference tuning |
| Ascend chip architecture: AIC/AIV, memory hierarchy, A2A3 vs. A5 |
| HCCL, comm windows, CANN container verify, distributed execution |
| Performance tuning: block_dim, swimlanes, PMU, arch-specific backend handlers |
| Developer NPU verification handoff — container checkout, HCCL STs, record SHA |
| PyTorch/HCCL collective + p2p bandwidth benchmarking via |
| Sync Dockerfile SHA pins to latest |
route_task returns agent_verify_tasks (safe for an agent to run, e.g. sim-Docker UTs) separately from developer_verify_tasks (NPU/hardware-gated — an agent must never run these; they're for the human developer, typically via generate_verify_handoff).
Host collectives (plan 33)
Agent | Task |
Sim UT gate |
|
NPU ST (developer) |
|
Read hw-native-sys://notes/host_collectives before resuming fork work in this area, and hw-native-sys://agent/distributed_work_policy (sim known failures) before running distributed STs in sim.
Configuration files
File | Purpose | Curation |
| Workspace root, repo paths, named tasks, | Hand-maintained |
| Task routes, resources, notes topics | Hand-maintained |
| Repo → agent-skill directory map (inventory read live from each repo's SKILL.md frontmatter) | Hand-maintained |
| Per-repo code entrypoints, by area | Hand-maintained |
| Hand-curated compiler/stack concept cards | Hand-maintained — always wins over generated cards on name collision |
| Ascend hardware, arch, HCCL concept cards | Hand-maintained, merged into the same abstraction index as |
| ~150 pto-isa instruction cards (tile-local + comm) | Generated by |
| ~510 PTOAS IR op cards | Generated by |
| Default pipeline pass order, phase, verify tasks | Generated by |
| Structured PR status | Generated by |
| Structured collective-comm parity matrix | Generated by |
| L0–L6, the three engines, scheduler | Generated by |
| Model workloads and prefill/decode kernel names | Generated by |
| MCP-owned decision trees (platform, alignment, HCCL) | Hand-maintained |
All generated files are checked into git (so a fresh checkout works without a build step) but are meant to be periodically regenerated — see below. None of the generator scripts ever write to the sibling repos or to pypto-3.0-notes; they only read from them.
Provenance: curated vs. generated abstraction cards
load_abstractions() merges, in order: pto_isa_generated.json, ptoas_generated.json, the cards objects inside simpler_scheduler.json and pypto_lib_workloads.json, then abstractions.json and ascend_abstractions.json. Any hand-curated card always wins outright on an exact name collision. explain_abstraction reports which one you got via its source field (curated or generated). Generated instruction and op cards additionally carry generated_from (the exact source file scraped).
Why this split exists: pto-isa and PTOAS have far more instructions/ops (about 150 and 510) than the hand-curated cards (about 80 combined). Rather than leave the long tail undocumented, the generators mechanically extract what pto-isa/PTOAS already document about themselves (structured manifest.yaml entries, TableGen let summary fields) — lower-quality than hand curation, but far better than nothing, and it never silently overrides a hand-written card.
Maintaining the knowledge config
Run these after upstream changes to the scraped sources (pass pipeline, pto-isa manifest, PTOAS .td files, PR/plan status, or the collective status matrix). For a full refresh in one command:
# Regenerate every generated index, re-stamp config/.index_build_time, then audit
./tools/refresh_all.shOr run the steps individually when only one source changed:
# Verify every path referenced by knowledge.json/abstractions/entrypoints actually exists
python tools/verify_knowledge_config.py
# Rebuild passes_index.json (from pypto's pass_manager.py) + suggest new abstraction
# candidates (printed to stdout only -- never auto-merged into abstractions.json)
python tools/build_knowledge_index.py
# Rebuild pto_isa_generated.json from pto-isa/docs/isa/manifest.yaml + comm/README.md
python tools/build_pto_isa_index.py
# Rebuild ptoas_generated.json from PTOAS's PTOOps.td / VPTOOps.td
python tools/build_ptoas_index.py
# Sync status_prs.md -> program_status.json for agents
python tools/sync_status_to_json.py
# Sync current_status.md's parity matrix -> collective_status.json
python tools/sync_collective_status_to_json.py
# Rebuild simpler_scheduler.json from scheduler directories plus the L0-L6 table
python tools/build_simpler_scheduler_index.py
# Rebuild pypto_lib_workloads.json from the model index and models/ directories
python tools/build_pypto_lib_workloads.pyCaveat on build_knowledge_index.py: it only rebuilds passes_index.json when re-run explicitly — load_passes_index() does not invalidate the on-disk cache on its own (unlike load_abstractions(), which is mtime-keyed). The scraper matches passes.<name> factory references inside pass_manager.py's _get_pass_factories body (the old ("Name", lambda: passes.foo()) PassSpec tuples are gone — the pipeline now runs through a C++ PassPipeline but the recipe is still a Python tuple list of factories). If a rebuild returns pypto_pass_count as 0 with a warning, upstream moved away from that shape again — inspect the recipe before assuming the scraper is simply stale. Don't blindly overwrite a healthy checked-in cache with a broken re-scrape — diff it first; if the rebuild produces materially less data than what's committed, something upstream changed and needs a matching fix in passes_index.py, not a cache overwrite.
Pre-commit gate
tools/hooks/pre-commit runs ruff + tools/verify_knowledge_config.py + the
test suite before every commit, so config drift (stale refs, missing skill
paths, broken routes) never lands. Install once per clone:
git config core.hooksPath tools/hooksCI and knowledge freshness
.github/workflows/ci.yml runs the lint gate (ruff, pinned to 0.14.8 with an
explicit rule set in pyproject.toml) and the sandboxed test subset
(pytest -m "not workspace") on every push/PR — it needs only this repo. The
sibling repos (pypto, pypto-3.0-notes, …) are private and cannot be cloned
anonymously, so the workspace-dependent pieces run locally instead:
the full test suite incl. the
@pytest.mark.workspacesmoke tests (pytest tests/from the workspace),the knowledge-config audit (
tools/verify_knowledge_config.py),the freshness drift guard
tools/check_fresh.sh— regenerate every generated cache and fail when the checked-in indexes have drifted from the upstream sources (ignores the re-stampedconfig/.index_build_time):
bash tools/check_fresh.shThe pre-commit hook above runs all three on every local commit, so CI and local together cover the full gate.
Self-auditing: knowledge_health
Call knowledge_health any time you want a health check on the knowledge layer itself, without a manual audit:
missing_paths— any route/resource/abstraction path that no longer exists on disk.stale_enriched— enriched docs whoselast_verified(frompypto-3.0-notes/NOTES_FRESHNESS.md) is more than 30 days old.coverage.pto_isa_indexed/coverage.ptoas_indexed— how many generated cards currently exist, so index drift (e.g. after a pto-isa/PTOAS refactor) is visible without re-running the multi-agent audit that originally found this gap.pypto_pass_count/pypto_passes_index_warning— whether the pass-pipeline scrape is currently healthy (see caveat above). Explicitly scoped to pypto — no other repo's pass pipeline is scraped, so don't read this as a cross-repo figure.scheduler_implementation_count/workload_count/catalog_issues— whether the simpler scheduler index and the pypto-lib workload catalog exist and are non-empty.ascend_issues,last_index_build,ascend_route_count— misc corpus checks.
Task profile (operations)
Balanced profile: fast daily tasks (git, lint) plus heavier tasks (docker, profiling, hardware tests). Warnings are surfaced by list_tasks, explain_task, and run_task. Destructive patterns (git reset --hard, git clean -fdx, rm -rf /, rm -rf ~) are blocked at the run_command/run_task layer regardless of which repo task config requests them.
Walkthroughs
Developer, lowering bug. Call layer_guide("ptoas") for that layer's docs, skills, and rules. Then explain_abstraction("tmov", layer="ptoas") and explain_abstraction("TMOV", layer="pto-isa") so the assembler op and the ISA instruction stay separate. If the failure is in the runtime, call explain_scheduler("L3") or explain_scheduler("hierarchical"). Then search_tracker("tmov", repo="PTOAS", state="merged") and the same query with state="open".
User, a model. Call list_workloads("deepseek_v4_1_flash") for the summary, serving support, and prefill/decode filenames. Then layer_guide("pypto-lib") for that layer's docs and rules. Read a page with read_doc.
NPU queue. Call explain_task_queue before any hardware handoff. Queue hosts are 192.168.150.11 and .12. Host .13 and sim images are not queued. The handoff from generate_verify_handoff wraps developer commands as task-submit --device auto --device-num N --max-time 3600 --timeout 0 --run '… $TASK_DEVICE'. Put LD_PRELOAD inside --run. The full recipe is pypto-docker/TASK_QUEUE.md. The agent does not submit the job.
Example agent prompts
"Invoke
start_compiler_workwith area=codegen_orchand follow the bootstrap.""
route_taskforhost_collectives_program— sim Docker UT vs NPU ST split.""
explain_abstractionforhost_collectives_program.""
explain_abstractionforBackendHandler910B— when is GM pipe buffer required?""
explain_abstractionforTSCATTER— note it covers both the local-tile and collective-comm meaning, merged from two sources.""
route_taskascend_runtime— HCCL windows and container flags.""
ascend_env_checkthengenerate_verify_handofffor branch feat/foo.""
search_abstractionshccl window.""
explain_abstractionforIterArgCarryAnalyzer.""
trace_in_stackforpypto/src/codegen/pto/pto_codegen.cpp.""
search_abstractionsfor allreduce.""
collective_statuswith axis=Dynamic NR— what's the parity gap across ops?""
knowledge_health— any stale or missing docs, or coverage gaps?""
route_taskdebug_codegen— how do I inspect pass dumps / .pto / kernel C++ for this lowering bug?""
read_doccontent/debug/codegen-inspection.mdthenfind_generated_artifactsfor programqwen_decode.""
find_skill— which workflow diffs generated code between branches?""
layer_guideptoas — which rules and skills apply before I edit an op?""
explain_schedulerhierarchical — which queue does a SUB task use?""
list_workloadsdeepseek_v4_1_flash — which files are prefill?""
search_trackerTMOV state=merged repo=PTOAS,pto-isa — was this already fixed?""
explain_task_queue— does this host require task-submit?"
PR watch CLI
pr_watch is also exposed as hw-native-sys-pr-watch, so a shell/agent loop can
poll without an MCP client:
hw-native-sys-pr-watch --repo pypto --pr 3248 --format summary
# stateful watch: persist the cursor and body hashes between polls
hw-native-sys-pr-watch --repo pypto --branch feat/x \
--state-file ~/.local/state/hw-native-sys/pr-watch/pypto-3248.json \
--update-state --format json--pror--branch;--since/--seenoverride the state file.The state file is written atomically only when the snapshot is complete; an incomplete page returns exit code
4and no cursor.Exit codes:
0success,2usage,3gh/transport/GraphQL error,4incomplete snapshot.The binary is installed by
pip install -e .(orpip install .). In this workspace it lives at$HOME/workspace/hw-native-sys/mcp-hw-native-sys/.venv/bin/hw-native-sys-pr-watch.
The workspace .mcp.json must use an absolute path to
.venv/bin/hw-native-sys-mcp (or be launched from the workspace root): a
relative mcp-hw-native-sys/... command resolves against the client's cwd and
fails with ENOENT when the client runs in pypto-3.0-notes.
Prerequisite notes
Simulator/CPU tests: Python deps and build toolchain.
Hardware tasks: Ascend runtime/device environment.
Docker tasks: daemon available; can be heavy on disk/network.
Profiling: start with
profiling_smokebeforeprofiling_full.
Extending this server
Every tool follows the same shape: a plain, unit-testable _impl(...) function (in mcp_hwnative_sys/<module>.py) plus a thin @mcp.tool()-decorated wrapper that calls it.
Put the real logic in a module-level
def foo_impl(...) -> dict[str, Any]— no MCP/pydantic types inside, so it can be imported and called directly from tests.Register it in
register_knowledge(mcp)(inknowledge.py) or directly inserver.py, usingAnnotated[T, Field(description=...)]for every parameter — the description is what the calling agent sees, so make it concrete (include example values). Prefer a local import inside the tool function body for the impl module (e.g.from mcp_hwnative_sys.foo import foo_impl) to avoid import cycles, matching the existing convention forexplain_pass,trace_contract,verify_ladder,collective_status, etc.Raise plain
ValueError/RuntimeError/FileNotFoundErrorfor user-facing errors — there's no custom exception hierarchy.Add a test in
tests/test_<module>.py: plainpytestfunctions (no classes),from __future__ import annotations,monkeypatch.setattr(<module>, "workspace_root", lambda: tmp_path)(or the relevant path function) to sandbox filesystem-touching code, plus one smoke test against the real workspace. If the tool lives intools/(a maintenance script, not part of the installed package), import it in tests via asys.path.insert(0, str(TOOLS_DIR))at the top of the test file, matchingtest_build_pto_isa_index.py/test_build_ptoas_index.py.Run
pytest tests/frommcp-hw-native-sys/(use the project's own.venv:.venv/bin/python -m pytest tests/).If your tool scrapes a source that could drift (like the pto-isa/PTOAS generators or the pass-pipeline scraper), prefer writing to a new generated JSON file that gets layered in at load time, rather than writing into a hand-curated config — that way hand edits are never at risk of being silently overwritten by a bad scrape, and regenerating is always safe to re-run.
Known caveats
passes_index.pyrecovers pass names by regex-scrapingpasses.<name>factory references insidepypto/python/pypto/ir/pass_manager.py's_get_pass_factoriesbody, deduplicated in source order. It is current as of the September 2026 recipe shape; if pypto changes the recipe syntax again (or moves pass description out of Python entirely), the scraper must be updated in the same change —knowledge_health'spypto_passes_index_warningis the tripwire, andtools/refresh_all.shregenerates the checked-in cache after any pass-pipeline change.Some
notes/*topics are defined both inresourcesandnotes_topics;register_knowledgededuplicates them at registration time (theresourcesentry, with its per-topicmax_chars, wins).
Available Tools
38 toolsascend_env_checkA
Read-only Ascend/CANN environment check: devices, HCCL preload, Docker hints.
Inputs: no named parameters. Returns: object
bootstrap_sessionB
Single-call session bootstrap: route metadata, read_plan, health, program hints, and a testing block (verify tasks, sim/NPU images, rules).
Inputs: task_type (required), detail, include_health. Returns: object
collective_statusA
Collective-comm feature parity status (merged/planned/gap) from the parity matrix in pypto-3.0-notes/distributed/current_status.md. Read-only -- never writes to the source doc.
Inputs: op, axis. Returns: object
explain_abstractionA
Explain a stack abstraction. If the name matches several layers, returns candidates instead of picking one.
Inputs: name (required), layer. Returns: object
explain_passA
Explain a pass in the Default pipeline: order, phase, neighbors, verify tasks.
Inputs: name (required). Returns: object
explain_schedulerC
Explain a simpler scheduler level (L0–L6), engine, or concrete implementation tree.
Inputs: name (required). Returns: object
explain_taskB
Show the exact command and metadata configured for a named task.
Inputs: repo (required), task (required). Returns: object
explain_task_queueA
Read-only task-submit queue guide: which hosts require it, how to join, and the failure rules. Does not submit a job.
Inputs: no named parameters. Returns: object
find_entrypointsB
Find code entrypoints for a repo and optional area (e.g. pypto, codegen_orch).
Inputs: repo (required), area. Returns: object
find_generated_artifactsA
Locate generated-code artifacts across the workspace: pass dumps, .pto MLIR, kernel/orchestration C++, dfx outputs.
Scans each repo's build_output/outputs/build roots (read-only) and classifies what it finds. Combine with the debug/codegen-inspection resource to know which stage each artifact belongs to.
Inputs: kind, repo, max_results, program_hint. Returns: object
find_skillA
Find the agent skill that matches a task across all repos' skill corpus.
Inputs: query (required), repo. Returns: object
gate_pr_scriptA
Generate a bash script for the safe rebase->pre-commit->sim-Docker-tests->squash->push gate workflow.
Inputs: repo (required), skip_tests, test_paths, base_branch, +3 more. Returns: object
generate_verify_handoffA
Generate markdown handoff for developer NPU verification in a container.
Inputs: repo (required), branch (required), sha, platform, +3 more. Returns: object
git_diffA
Return the git diff for a repository (stat + optional patch). Prefer stat_only=True for orientation.
Inputs: repo (required), ref, path, stat_only. Returns: object
git_logA
Return the last N commits for a repository as structured data (sha, author, date, message).
Inputs: repo (required), n, ref. Returns: object
knowledge_healthA
Check knowledge config health: missing paths, stale enriched docs, Ascend corpus, index build time.
Inputs: no named parameters. Returns: object
layer_guideC
Docs, skills, and rules for one framework layer, read live from that repo.
Inputs: layer (required), topic. Returns: object
list_knowledge_topicsA
List available task routes, MCP resources, notes topics, and bootstrap prompts.
Inputs: no named parameters. Returns: object
list_repositoriesA
List configured repositories, their paths, and architecture metadata.
Inputs: no named parameters. Returns: result
list_skillsB
List the agent-skill corpus per repo (pypto, pypto-lib, simpler, PTOAS, pto-isa, pypto-* plugins, pypto-tooling).
Inputs: repo. Returns: object
list_tasksA
List available named tasks for a repository, including metadata and warnings.
Inputs: repo (required), include_command. Returns: object
list_task_typesA
Return all valid task_type values with one-line descriptions for use with bootstrap_session and route_task.
Inputs: no named parameters. Returns: result
list_workloadsA
List pypto-lib model workloads, or one model's kernels split into prefill and decode.
Inputs: name. Returns: object
program_statusA
Structured PR/plan status from status_prs.md (open PRs, blockers, plan cross-index).
Inputs: no named parameters. Returns: object
pr_watchA
Read-only one-shot PR snapshot: CI rollup, review decision, unresolved threads, reviews, comments, and new-only deltas. Never posts; the caller owns the watch cadence.
Inputs: repo (required), number (required), since, seen_ids, +1 more. Returns: object
read_docA
Read a workspace document with tier labeling. Optional section extracts a markdown heading.
Inputs: path (required), section, max_chars. Returns: object
read_fileA
Read an arbitrary source file from a repository without shelling out.
Inputs: path (required), repo (required), offset, max_lines. Returns: object
repository_healthA
Get branch, dirty state, and ahead/behind for every configured repo.
Inputs: include_clean. Returns: object
route_taskB
Return read-first docs, rules, entrypoints, and verify tasks for a compiler workflow.
Inputs: task_type (required), detail. Returns: object
run_commandA
Run an ad-hoc shell command in a repository. Prefer run_task for known tasks or git_log/git_diff/read_file for read-only operations.
When no NPU is reachable, build/test commands (cmake, make, ninja, pip install, pytest, …) are refused — those must run inside the sim Docker images, never on the local repo. Read-only commands are unaffected.
Inputs: repo (required), command (required), timeout_seconds. Returns: object
run_taskA
Run a configured task in a repository.
Build/test tasks are routed by NPU availability: with NPUs reachable they run on the host (allowed by policy); without NPUs they are re-routed into the sim Docker image for the repo (see _SIM_RUN), or refused with guidance when the repo has no sim image (e.g. PTOAS).
Inputs: repo (required), task (required), extra_args, timeout_seconds. Returns: object
search_abstractionsB
Search the abstraction index by keyword. Results are ranked by relevance and grouped by layer.
Inputs: query (required), layer, fields, max_results. Returns: object
search_codeB
Search code across repos. mode=locations (default) omits line text; mode=context includes context.
Inputs: query (required), mode, repo, file_glob, +4 more. Returns: object
search_trackerB
Search open, closed, and merged GitHub issues and PRs. Read-only.
Inputs: query (required), kind, repo, state, +1 more. Returns: object
summarize_profileA
Summarize a pypto-profiling campaign directory (results.json, anomalies).
Inputs: run_dir (required). Returns: object
trace_contractA
Full cross-layer trace: stack location + contract triangle + cross-layer verify tasks + active-PR links.
This is the enriched trace. Use trace_in_stack for a lightweight stack-location-only lookup.
Inputs: symbol_or_path (required). Returns: object
trace_in_stackA
Lightweight stack location: matched abstraction card or path-prefix pipeline stage only.
No contract artifacts or PR links. Use trace_contract for the enriched cross-layer trace.
Inputs: symbol_or_path (required). Returns: object
verify_ladderA
Suggest minimal verify tasks for a set of changed file paths.
Returns static_checks (e.g. ["clang-tidy"]) when a changed path
is a C/C++ file in a C++ repo — run those before the pytest tasks
(see tools/clang_tidy_workflow).
Inputs: changed_paths (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 38 tools
Several clusters overlap heavily: explain_task/explain_pass/explain_abstraction/layer_guide all explain stack concepts, and trace_contract vs trace_in_stack plus find_skill vs search_abstractions require reading long descriptions to choose correctly. A few pairs are explicitly cross-referenced (pr_watch vs program_status, list_task_types vs list_tasks), which helps, and the list_ family is mostly domain-distinct. Still, an agent must read carefully in the explanation/trace/skill-search family to avoid misselection.
Everything is snake_case and most names follow a verb_noun pattern (list_repositories, search_code, run_task, find_entrypoints, generate_verify_handoff). A minority are noun-first status/guide tools (program_status, repository_health, collective_status, knowledge_health, layer_guide, bootstrap_session), which is a minor but visible deviation. The pattern is predictable enough that an agent can guess names.
38 tools is well past the comfortable range and the surface spans many sub-domains (repos, tasks, docs, abstractions, skills, artifacts, PRs, health, profiling, workloads). Several tools look like narrow conveniences (collective_status, summarize_profile, explain_task_queue) that add selection cost. The set would benefit from consolidation into broader routing tools.
The read-oriented lifecycle is well covered: discovery (list_knowledge_topics, list_repositories, list_skills), orientation (bootstrap_session, route_task, layer_guide), inspection (git_log, git_diff, read_file, find_generated_artifacts), verification (verify_ladder, generate_verify_handoff), and health checks. Gaps are mostly intentional read-only boundaries (no queue submission, no PR posting, no task editing), so agents must fall back to run_command or external tooling for writes.
Maintenance
Related MCP Connectors
Ask a codebase what calls what: search, blast radius, paths between symbols, and diffs.
Search indexed code, trace dependencies, assess change impact, and recall repository memory.
Build, test and cache insights for Xcode, Gradle and Bazel projects, for coding agents.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides semantic code intelligence tools (search, structural views) and a workspace TUI interface for LLM agents to efficiently navigate codebases, manage context, and maintain architectural patterns across Python, Java, C++, and Perl projects.4MIT
- AlicenseAqualityCmaintenanceEnables AI coding agents to retrieve cited git-history explanations for files and tickets, compile a Team Engineering Contract from repository artifacts, and follow guided Understand/Build workflows over MCP stdio. It lets clients such as Grok, Claude Code, Codex, Kiro, and Cursor share the same tools for evidence-backed repository understanding.11 npmApache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables IDEs and coding agents to perform fast deterministic repository queries, symbol and dependency graph navigation, persistent memory recall, skill loading, security scanning, git inspection, and model routing with minimal token usage.MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to query a parsed graph of a repository and to recall what earlier sessions learned about it, both stored in FalkorDB behind one traversal. It exposes eight MCP tools over stdio for locating symbols, tracing calls and impact paths, and writing or recalling user- and repo-scoped facts, procedures, and handoffs.311,836 npmMIT