# agent-mcts

> agent-mcts is an open-source agent for coding. Wraps a coding agent CLI in tree search so it tries several attempts and keeps the best. It is available on CLI, Linux, macOS, Windows and Self-hosted.

- **Kind:** Agent
- **Pricing:** Open source
- **Platforms:** CLI, Linux, macOS, Windows, Self-hosted
- **Repository:** https://github.com/natsu0529/agent-mcts
- **Categories:** [coding](https://ai-powered.com/categories/coding-agents)
- **Listing updated:** 2026-11-27

## About

Most coding agents make one linear pass at a task: try, observe, retry in place. agent-mcts runs the same agent as a Monte Carlo Tree Search instead. Each attempt is made in its own git worktree, scored against tests, and the most promising attempts are revised further while your working tree stays untouched.

Scoring relies on your project's test command, optionally extended with tests an agent writes from the task description, or an LLM judge that reads each attempt's diff. Failing output from one attempt is passed into the revision prompts of its children, so the search learns what to fix. Every node is saved as a git branch, and an interrupted run still leaves an inspectable tree.

The tool is aimed at developers who already use Claude Code and want more reliable results on well-specified tasks. Its own benchmark reports gains on two tasks with written specs and no clear gain on a vague bug report, so it is best suited to tasks where tests can express what done looks like.

## Features

- **Tree search over attempts:** Explores several branches of agent attempts using UCT selection and backs up scores to guide the budget.
- **Isolated git worktrees:** Each attempt runs in its own worktree, so your working tree changes only when you apply a result.
- **Test-based scoring:** Scores attempts by exit code and pass ratio from pytest, jest, cargo test, go test and JUnit-style output.
- **Generated tests option:** Lets an agent write extra tests from the task and scores every attempt against them.
- **LLM judge option:** Scores each attempt's diff with a model when tests are not enough.
- **Live terminal tree and resume:** Shows the search tree as it grows and can resume an interrupted run with a larger budget.

## Good for

- Getting a more reliable fix from a coding agent on a task with a written spec
- Comparing several agent attempts at a bug and applying the best one
- Running a bounded, cost-capped search over an agent for a test-driven change
- Studying test-time search over real software tasks as a research harness

## FAQ

### Which coding agents does agent-mcts support?

Claude Code is verified. A Codex CLI adapter ships but has only been tested against a fake codex binary. A Kimi CLI adapter is planned.

### Is agent-mcts open source?

Yes, it is released under the MIT license.

### How are attempts applied to my project?

Running apply stages the chosen node's changes as a squash merge, so you review and commit them yourself.

### How do I install agent-mcts?

Install with uv tool install agent-mcts, then run agent-mcts run with a task description inside your project.

### Is agent-mcts free?

Yes. agent-mcts is open source, so you can use and self-host it for free.

### What are the best alternatives to agent-mcts?

The closest alternatives to agent-mcts are CoderBaba, agent-orchestrator, Github, munder-difflin and gpt-pilot.

## Where this comes from

- Description: written from the project's README.

## Alternatives

- [CoderBaba](https://ai-powered.com/agents/coderbaba): CoderBaba is a free open-source agent for coding.
- [agent-orchestrator](https://ai-powered.com/agents/agent-orchestrator): agent-orchestrator is an open-source agent for coding.
- [Github](https://ai-powered.com/agents/github-2): Github is an open-source agent for developer tools.
- [munder-difflin](https://ai-powered.com/agents/munder-difflin): munder-difflin is an open-source agent for multi-agent frameworks.
- [gpt-pilot](https://ai-powered.com/agents/gpt-pilot): gpt-pilot is an open-source agent for coding.
- [Agav](https://ai-powered.com/agents/agav): Agav is an open-source agent for coding.
- [command-code](https://ai-powered.com/agents/command-code): command-code is a paid hosted agent for coding.
- [Codewhale](https://ai-powered.com/agents/codewhale): Codewhale is an open-source agent for coding.

---
Source: https://ai-powered.com/agents/agent-mcts
