Qiskit Gym MCP Server

v0.4.2
io.github.Qiskit/qiskit-gym-mcp-server Checked 18 hours ago Published 1 month ago

MCP server for qiskit-gym reinforcement learning quantum circuit synthesis

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

create_permutation_env_tool

Create a PermutationGym environment for learning qubit routing with SWAP gates. Use this to create an RL environment that learns to implement arbitrary qubit permutations using minimal SWAP gates on constrained coupling maps.

ParameterTypeDescription
coupling_mapCustom coupling map as list of [qubit1, qubit2] edges. Example: [[0,1], [1,2], [2,3]] for a linear chain.
presetHardware preset name (use instead of coupling_map). Options: "ibm_heron_r1", "ibm_heron_r2", "ibm_nighthawk", "grid_3x3", "grid_5x5", "linear_5", "linear_10"

create_linear_function_env_tool

Create a LinearFunctionGym environment for learning CNOT synthesis. The environment learns to decompose linear Boolean functions into efficient quantum circuits using CNOT gates.

ParameterTypeDescription
basis_gatesOptional list of basis gates (default: ["cx"])
coupling_mapCustom coupling map as list of [qubit1, qubit2] edges.
presetHardware preset name (e.g., "ibm_nighthawk", "grid_3x3")

create_clifford_env_tool

Create a CliffordGym environment for learning Clifford circuit synthesis. The environment learns to synthesize optimal implementations of Clifford group elements using a customizable gate set.

ParameterTypeDescription
num_qubits *integerNumber of qubits for the environment
coupling_mapCustom coupling map (optional)
gatesetCustom gate set. Can be: - List of gate names: ["H", "S", "CX"] (applied to all qubits/edges) - List of dicts: [{"gate": "H", "qubits": [0]}, {"gate": "CX", "qubits": [0, 1]}]
presetHardware preset name (optional)

list_environments_tool

List all active RL environments. Returns: Dict with list of environments and their info.

get_environment_info_tool

Get detailed information about a specific environment.

ParameterTypeDescription
env_id *stringEnvironment ID

delete_environment_tool

Delete an environment.

ParameterTypeDescription
env_id *stringEnvironment ID to delete

start_training_tool

Start training an RL agent on a created environment. This initiates training that learns to synthesize optimal circuits.

ParameterTypeDescription
env_id *stringEnvironment ID from create_*_env_tool
algorithmstringRL algorithm to use: - "ppo": Proximal Policy Optimization (recommended, faster) - "alphazero": AlphaZero-style MCTS (better for complex problems)
backgroundbooleanIf True, run training in background and return immediately. Use get_training_status_tool to poll progress, or wait_for_training_tool to block until done. Default: False (synchronous).
num_iterationsintegerNumber of training iterations. Default: 100
policystringNeural network policy architecture: - "basic": Simple feedforward network (faster, good for small problems) - "conv1d": 1D convolutional network (better for larger problems)
tensorboard_experimentName for TensorBoard logging (optional)

batch_train_environments_tool

Train multiple environments in sequence. Useful for training models across multiple topologies or subtopologies extracted from hardware.

ParameterTypeDescription
env_ids *arrayList of environment IDs to train
algorithmstringRL algorithm to use
backgroundbooleanIf True, start all training in background and return immediately. Use get_training_status_tool or wait_for_training_tool to monitor.
num_iterationsintegerNumber of iterations per environment
policystringNeural network policy architecture
tensorboard_prefixPrefix for TensorBoard experiment names

get_training_status_tool

Get the status and metrics of a training session.

ParameterTypeDescription
session_id *stringTraining session ID

get_training_metrics_tool

Get detailed training metrics from TensorBoard logs. Returns the progression of difficulty, success rate, and reward throughout training. Use this after training completes to understand how well the model trained and what difficulty level it reached.

ParameterTypeDescription
session_id *stringTraining session ID

wait_for_training_tool

Wait for a background training session to complete. Blocks until training completes, fails, or times out. Use this after starting training with background=True.

ParameterTypeDescription
session_id *stringTraining session ID to wait for
timeoutintegerMaximum time to wait in seconds (default: 600 = 10 minutes)

stop_training_tool

Stop a training session.

ParameterTypeDescription
session_id *stringTraining session ID to stop

list_training_sessions_tool

List all training sessions. Returns: Dict with list of training sessions.

list_tensorboard_experiments_tool

List available TensorBoard experiments from past training runs. Returns a list of experiment names that can be used with get_tensorboard_metrics_tool to view historical training metrics. Returns: Dict with list of experiment names (newest first).

get_tensorboard_metrics_tool

Get training metrics from TensorBoard logs for historical runs. Use this to read metrics from past training runs that are no longer in the active session list. Use list_tensorboard_experiments_tool to see available experiments.

ParameterTypeDescription
experiment_nameName of the TensorBoard experiment (e.g., "linear_function_train_0001_abc123").
tensorboard_pathDirect path to TensorBoard logs (alternative to name).

start_tensorboard_tool

Start TensorBoard to visualize training metrics. Launches TensorBoard as a background process using the configured QISKIT_GYM_TENSORBOARD_DIR as the log directory.

ParameterTypeDescription
portintegerThe port to run TensorBoard on (default: 6006)

stop_tensorboard_tool

Stop the running TensorBoard process. Terminates the TensorBoard process that was started with start_tensorboard_tool. Returns: Dict with status message indicating whether TensorBoard was stopped.

get_tensorboard_status_tool

Check the status of the TensorBoard process. Returns whether TensorBoard is running and on which port. Returns: Dict with running status, port, and URL if running.

synthesize_permutation_tool

Synthesize an optimal quantum circuit for a qubit permutation. Uses a trained PermutationGym model to find an optimal SWAP gate sequence that implements the desired qubit permutation on the coupling map.

ParameterTypeDescription
model_id *stringID of a loaded PermutationGym model
permutation *arrayTarget permutation as list of qubit indices. Example: [2, 0, 1] means qubit 0 -> position 2, qubit 1 -> position 0
deterministicbooleanIf True, use deterministic action selection
num_searchesintegerNumber of search attempts. Higher = better results. Max: 10000

synthesize_linear_function_tool

Synthesize an optimal quantum circuit for a linear Boolean function. Uses a trained LinearFunctionGym model to find an optimal CNOT circuit.

ParameterTypeDescription
linear_function *arrayNxN binary matrix representing the linear function. Entry [i][j]=1 means output i depends on input j (XOR).
model_id *stringID of a loaded LinearFunctionGym model
deterministicbooleanIf True, use deterministic action selection
num_searchesintegerNumber of search attempts. Max: 10000

synthesize_clifford_tool

Synthesize an optimal quantum circuit for a Clifford operation. Uses a trained CliffordGym model to find an optimal Clifford implementation.

ParameterTypeDescription
clifford_tableau *Clifford tableau in standard (2N+1 x 2N) format, or dict with "destab" and "stab" matrices.
model_id *stringID of a loaded CliffordGym model
deterministicbooleanIf True, use deterministic action selection
num_searchesintegerNumber of search attempts. Max: 10000

save_model_tool

Save a trained model to disk. Save by session_id (from just-completed training) or model_id (loaded model).

ParameterTypeDescription
model_idModel ID (alternative to session_id)
model_nameName to save as (defaults to auto-generated)
session_idTraining session ID (from start_training result)

load_model_tool

Load a saved model from disk.

ParameterTypeDescription
model_name *stringName of the model to load

list_saved_models_tool

List all models saved to disk. Returns: Dict with list of saved models.

list_loaded_models_tool

List all models currently loaded in memory.

ParameterTypeDescription
filter_typeOptional filter by env_type or model name prefix

delete_model_tool

Delete a model.

ParameterTypeDescription
model_name *stringName of the model to delete
delete_filesbooleanIf True, also delete saved files from disk

get_model_info_tool

Get detailed information about a model.

ParameterTypeDescription
model_idModel ID (for loaded models)
model_nameModel name (can also check saved models on disk)

create_coupling_map_tool

Create a custom coupling map.

ParameterTypeDescription
bidirectionalbooleanWhether edges are bidirectional (default: True)
colsNumber of columns (for grid topology)
edgesCustom edges as [[q1, q2], ...] (mutually exclusive with topology)
num_qubitsNumber of qubits (for line topology)
rowsNumber of rows (for grid topology)
topologyTopology type ("grid", "line") (mutually exclusive with edges)

extract_subtopologies_tool

Extract connected subtopologies of N qubits from a hardware preset. Use this to find all unique connected subgraphs of a specified size from a larger coupling map. Essential for training RL models on subtopologies of real quantum hardware like IBM Nighthawk.

ParameterTypeDescription
edgesCustom coupling map edges (alternative to preset)
max_subtopologiesintegerMaximum number of subtopologies to return (default: 50)
num_qubitsintegerNumber of qubits for subtopologies (default: 4)
presetHardware preset name (e.g., "ibm_nighthawk", "ibm_heron_r1")

list_subtopology_shapes_tool

List available subtopology shapes for a given hardware and qubit count. Summarizes the types of subtopologies available (line, grid, star, etc.) without returning all edges.

ParameterTypeDescription
num_qubits *integerNumber of qubits for subtopologies
preset *stringHardware preset name

get_fake_backend_coupling_map_tool

Get the exact coupling map from a fake IBM backend (no credentials needed). Use this to get exact IBM Quantum hardware topologies without needing IBM Quantum credentials. This is the recommended way to get accurate topologies for offline development.

ParameterTypeDescription
backend_name *stringBackend name (e.g., "ibm_fez", "ibm_brisbane", "ibm_boston", "ibm_sherbrooke"). Use list_available_fake_backends to see all options.

list_available_fake_backends_tool

List all available fake backends for offline topology access. Returns a list of IBM Quantum backends that have fake versions available in qiskit-ibm-runtime. These provide exact coupling maps without needing IBM Quantum credentials. Returns: Dict with list of backends, their qubit counts, and usage instructions.

generate_random_permutation_tool

Generate a random permutation for testing synthesis.

ParameterTypeDescription
num_qubits *integerNumber of qubits

generate_random_linear_function_tool

Generate a random invertible linear function for testing.

ParameterTypeDescription
num_qubits *integerNumber of qubits

generate_random_clifford_tool

Generate a random Clifford element for testing.

ParameterTypeDescription
num_qubits *integerNumber of qubits

convert_qpy_to_qasm3_tool

Convert a QPY circuit to human-readable QASM3 format. Use this tool to view the contents of a QPY circuit output from synthesis tools (like synthesize_permutation, synthesize_linear_function, synthesize_clifford) in a human-readable OpenQASM 3.0 format.

ParameterTypeDescription
circuit_qpy *stringBase64-encoded QPY circuit string (from synthesis output)

convert_qasm3_to_qpy_tool

Convert a QASM3 (or QASM2) circuit to base64-encoded QPY format. Use this tool to convert human-readable QASM circuits to QPY format, which preserves full circuit fidelity. The QPY output can be used with synthesis tools that may require circuit input.

ParameterTypeDescription
circuit_qasm *stringOpenQASM 3.0 or 2.0 circuit string