SuperAPI AI Directory

optuna-mcp

🎖️ 🐍 🏠 🐧 🍎 - Orchestrate hyperparameter search and other optimization tasks with Optuna.

Open website

About this tool

Optuna MCP Server is a Model Context Protocol (MCP) server designed to automate the process of optimization and analysis using Optuna. It interacts with the Optuna API through the MCP protocol, enabling LLMs and MCP clients to directly call Optuna's functionality.

Purpose The server can be used in the following scenarios:

  • Automatic execution of hyperparameter optimization by LLMs.
  • Interactive analysis of Optuna's optimization results through a chat interface.
  • Optimization of the inputs and outputs of other MCP tools.

Main Capabilities The server provides a series of tools covering Optuna's core functionality:

  • Study management: create_study (create or load a study, requires specifying study_name and optional directions), get_all_study_names, set_sampler, get_directions, set_metric_names, get_metric_names.
  • Trial operations: get_trials (retrieve all trials in CSV format), best_trial, best_trials (return the trials on the Pareto front), ask (suggest new parameters based on the search space), tell (report trial results, requires trial_number and values), set_trial_user_attr, get_trial_user_attrs.
  • Visualization: plot_optimization_history, plot_hypervolume_history, plot_pareto_front, plot_contour, plot_parallel_coordinate, plot_slice, plot_param_importances, plot_edf, plot_timeline, plot_rank, all return images.
  • Dashboard: launch_optuna_dashboard (port can be specified, default 58080).

Usage Installation can be done via uv or Docker. Taking Claude Desktop as an example:

  1. Install uv from Astral.
  2. Add the Optuna MCP server configuration in Claude Desktop's claude_desktop_config.json (see the official documentation for the specific configuration).
  3. The Optuna storage can be specified via the --storage parameter to persist results.
  4. Restart Claude Desktop. When using Docker, make sure Docker is installed and running.

Applicable Scenarios

  • Optimize the 2D-Sphere function.
  • Launch the Optuna dashboard to analyze optimization results.
  • Optimize FFmpeg encoding parameters (such as x264 options to maximize SSIM while controlling encoding time).
  • Optimize a cookie recipe (refer to the paper "Bayesian Optimization for a Better Dessert").
  • Optimize Matplotlib configuration.

Limitations The parameter details of some tools (such as the possible values for set_sampler's name) are not fully expanded in the original text and are not provided for now. Other limitations are not provided for now.

This project is licensed under the MIT License.