MCTS-Gen: A Generic MCTS Framework
This project provides a generic Monte Carlo Tree Search (MCTS) framework. Its core concept is the replacement of the Genetic Programming (GP) engine from chess-ant with a modern AI agent. While inspired by AlphaZero, it uses a simpler, decoupled approach: the standard UCT algorithm is augmented by an external AI agent that provides policy and value predictions.
Features
- AI-Augmented UCT: Utilizes the standard UCT algorithm. The AI agent enhances the search by providing value predictions and, most importantly, by performing Policy Pruning—narrowing the search space by supplying a pre-filtered list of promising moves.
- AI Agent Integration: Exposes the MCTS engine as a set of tools, enabling seamless integration with AI agents like the Gemini CLI.
- Extensible Game Logic: Easily add support for new games by creating a new game state module.
- Optional Dependencies: Install support for specific games on demand (e.g.,
pip install mcts-gen[shogi]).
Quickstart
1. Installation
Standard Installation
The core package can be installed directly using pip:
pip install mcts-gen
Installation with Game-Specific Dependencies
To include support for specific games, you can install optional dependencies.
-
For Shogi support:
pip install mcts-gen[shogi]
This installs the
python-shogilibrary. -
For Chess support:
pip install mcts-gen[chess]
This installs the
python-chesslibrary. -
For Ligand Generation support:
pip install mcts-gen[ligand]
This installs
rdkitandpandasfor de novo ligand design capabilities.Additionally, this feature requires the external tool
fpocketfor identifying protein binding pockets. It can be installed on Debian/Ubuntu systems using snap:sudo snap install fpocket
-
For Gymnasium Physical Simulation support:
pip install mcts-gen[gymnasium]
This installs
gymnasiumfor physical control policy simulation (e.g.CartPole-v1).
2. Server Setup for Gemini CLI
To allow the Gemini agent to use the MCTS-Gen tools, you must register the server in your settings.json file. This allows the Gemini CLI to automatically manage the server process and provide the necessary context files.
Note on v0.0.2+: As of version 0.0.2, the core agent instructions are built-in. Specifying a context file is no longer required for standard operation. Only configure the context block if you wish to provide additional instructions to the agent.
Create or update your settings.json file with the following configuration:
{
"context": {
"fileName": [
"src/mcts_gen/AGENTS.md",
"GEMINI.md"
]
},
"mcpServers": {
"mcts_gen_simulator_server": {
"command": "python",
"args": [
"-m",
"mcts_gen.fastmcp_server"
]
}
}
}
Note: The context block tells the Gemini CLI to load AGENTS.md (and GEMINI.md if it exists), which is crucial for the agent to understand how to use the tools.
You can place this settings.json file in one of two locations:
- Project-Specific:
./.gemini/settings.json(inside this project directory) - Global:
~/.gemini/settings.json(in your home directory)
For an alternative setup method using the fastmcp command-line tool, please see the official guide:
Installation with uv (Recommended)
For a faster and more modern package management experience, we recommend using uv.
-
Install
pipxanduv:# Install pipx (a tool to install and run Python applications in isolated environments) sudo apt install pipx # Install uv using pipx pipx install uv
-
Set up the environment and install
mcts-gen:# Create a virtual environment in your project directory uv venv # Activate the environment source .venv/bin/activate # Install mcts-gen with Shogi support uv pip install mcts-gen[shogi]
To exit the virtual environment, simply run
deactivate. -
Configure
gemini-cliwithfastmcp: Instead of manually editingsettings.json, you can use thefastmcpcommand to automatically configure the tool server.fastmcp install gemini-cli .venv/lib/python3.12/site-packages/mcts_gen/fastmcp_server.py:mcp
This command will automatically detect and configure the
mcts_genserver, creating a.gemini/settings.jsonfile for you.Note on the
:mcpsuffix: The:mcpat the end is required becausefastmcp_server.pycontains multiple objects. This suffix explicitly tellsfastmcpwhich object is the MCP server instance to be run.
Agent Context Configuration with uv
Note on v0.0.2+: The instructions below are for older versions or for cases where you need to add custom, additional context. As of v0.0.2, specifying AGENTS.md is not required for the agent to function correctly.
If you installed the package using uv or pip, the AGENTS.md file is included inside the package. To allow the Gemini agent to use it, you need to specify its full path in your .gemini/settings.json file.
Add the path to the context.fileName list. The exact path may vary depending on your Python version and environment.
Example .gemini/settings.json:
{
"context": {
"fileName": [
".venv/lib/python3.12/site-packages/mcts_gen/AGENTS.md",
"GEMINI.md"
]
},
"mcpServers": {
"mcts_gen_simulator_server": {
"command": "uv",
"args": [
"run",
"fastmcp",
"run",
".venv/lib/python3.12/site-packages/mcts_gen/fastmcp_server.py:mcp"
]
}
}
}
For Maintainers: How to Release a New Version
The package publication process is automated using GitHub Actions.
a) Releasing to TestPyPI (for testing)
To release a version to the TestPyPI repository for verification, create and push a git tag with a -test suffix.
# Example for version 0.1.0
git tag v0.1.0-test1
git push origin v0.1.0-test1
b) Releasing to PyPI (Official)
To perform an official release, create and push a git tag that follows the semantic versioning format (e.g., vX.Y.Z).
# Example for version 0.1.0
git tag v0.1.0
git push origin v0.1.0
Development
Testing
To run all tests:
pytest
License
This project is licensed under the GPL-3.0-or-later license.
Metadata
Release files for mcts-gen 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcts_gen-0.0.6.tar.gz | 43.9 kB | With provenance | Details for mcts_gen-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcts_gen-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for mcts_gen-0.0.6-py3-none-any.whl |
Total release size: 90.5 kB
Release files / mcts_gen-0.0.6.tar.gz
| Download URL | mcts_gen-0.0.6.tar.gz |
|---|---|
| Size | 43.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
305546d9c54628fe1479c209fcfce1711dfb7e39036c9c4ea9d76cc2694da8f9
|
|
BLAKE2b-256 checksum How to use checksums |
4579045eef2762201b4266f0e416dd015db665c8aef234f2e09758fe4c9118fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logRelease files / mcts_gen-0.0.6-py3-none-any.whl
| Download URL | mcts_gen-0.0.6-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
083a39ff1c92f44bcd9cde76a368bda6523c812477b084b19165174214590982
|
|
BLAKE2b-256 checksum How to use checksums |
bd90a658bd212feb7623793ea3488dc535c929a1946fa5ed64e6ec1253f48062
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logSecurity for mcts-gen 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mcts_gen-0.0.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.