Skip to content
Back to skills

Mctx

ASecurity

"Use Mctx for JAX-native Monte Carlo tree search, MuZero/Gumbel

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 8, 2026
businesspythonnodegitapibackend

Works with

  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 8 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill mctx --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mctx?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mctx
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-mctx/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-mctx)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mctx
description: "Use Mctx for JAX-native Monte Carlo tree search, MuZero/Gumbel
  MuZero policies, stochastic MuZero search, and search-tree inspection."
metadata:
  disco-role: operating
disable-model-invocation: true
license: Apache 2.0
---

# Mctx

Mctx is a compact JAX library for batched Monte Carlo tree search. Use this
skill when the task asks you to plan with a learned model, improve a policy
with search, or inspect the resulting search tree.

## Start here

- Install the library with `pip install mctx`.
- If you want a quick health check, run `python scripts/check_install.py`.
- If you want a safe runnable example, run
  `python scripts/policy_improvement_demo.py --num_runs=1`.
- Read `references/api-reference.md` when you need exact function signatures or
  tensor-shape contracts.
- Read `references/workflows.md` when you need an end-to-end recipe.
- Read `references/troubleshooting.md` when search output, shapes, or optional
  dependencies are failing.

## What this skill covers

### 1. Batched search on a learned model
Use `search(...)` when you already have:

- a batched root state,
- a recurrent model for expansion,
- a root action-selection function,
- an interior action-selection function,
- and a simulation budget.

This is the lowest-level entry point and is best when you need to customize the
search loop.

### 2. Classic MuZero-style planning
Use `muzero_policy(...)` when you want the standard MuZero policy improvement
loop with Dirichlet root noise, PUCT-style action selection, and visit-count
based action weights.

### 3. Gumbel MuZero planning
Use `gumbel_muzero_policy(...)` when you want the Gumbel MuZero variant and
its default Q-value completion strategy. This is the best default when the task
mentions policy improvement by planning with Gumbel.

### 4. Stochastic MuZero planning
Use `stochastic_muzero_policy(...)` when the environment alternates between
decision nodes and chance nodes. Provide separate decision and chance recurrent
functions; the wrapper handles the internal state structure.

## How to choose the right helper

- Use `qtransform_by_parent_and_siblings` for the default MuZero-style value
  normalization.
- Use `qtransform_completed_by_mix_value` for the default Gumbel MuZero path.
- Use `qtransform_by_min_max` when you already know a bounded Q-value range.
- Prefer the policy helper that matches the search style instead of reaching
  into `_src` internals.

## Inspecting results

After search, prefer the public summary APIs over raw tree fields unless you are
troubleshooting.

- `PolicyOutput.action` is the chosen action.
- `PolicyOutput.action_weights` are the training targets for the policy head.
- `PolicyOutput.search_tree` holds the final `Tree`.
- `Tree.summary()` exposes root visit counts, visit probabilities, value, and
  Q-values.
- `Tree.qvalues(node_index)` is the best way to inspect a node.

## Common input contract

- Treat action masks as `1 = invalid`, `0 = valid`.
- Keep root and recurrent outputs batched.
- Make `prior_logits` and `invalid_actions` have the same trailing action
  dimension.
- Keep `recurrent_fn` outputs aligned with the batch size of the root.
- Use `max_depth` only when you intentionally want to cap traversal depth.

## Bundled scripts

- `scripts/check_install.py` verifies the installed package, imports the public
  API, and reports the active JAX backend.
- `scripts/policy_improvement_demo.py` is a tiny bandit-style smoke demo that
  shows how planning can improve a policy.

## Optional dependency note

This skill does not bundle tree visualization. If you need Graphviz-style tree
rendering later, treat it as a separate dependency problem instead of assuming
it is available in a minimal install.

## When to read the deeper references

- Read `references/api-reference.md` before wiring a custom model or action
  mask.
- Read `references/workflows.md` before writing a new MuZero or Gumbel MuZero
  driver.
- Read `references/troubleshooting.md` when output is flat, invalid-action
  handling looks wrong, or JAX is on the wrong backend.
- Read `references/repo-provenance.md` when you need to check whether this
  skill is stale against the source checkout that produced it.

Files in this skill

  • SKILL.md4.1 KB
  • references/api-reference.md3.8 KB
  • references/repo-provenance.md1.3 KB
  • references/repo-routing-metadata.json434 B
  • references/troubleshooting.md2.9 KB
  • references/workflows.md3 KB
  • scripts/check_install.py822 B
  • scripts/policy_improvement_demo.py4.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.