by optuna
Interact with Optuna APIs through Model Context Protocol, providing primitive functions for study management, trial suggestion, result reporting, visualizations, and a web dashboard.
Enables automated hyperparameter optimization and analysis by exposing Optuna's core functionality as MCP tools. Clients can create studies, suggest and evaluate trials, retrieve metrics, and generate a variety of plots without writing Optuna code directly.
uvx optuna-mcpdocker run -i --rm --net=host -v /local/path:/app/workspace optuna/optuna-mcp:latest --storage sqlite:////app/workspace/optuna.db{
"mcpServers": {
"Optuna": {
"command": "uvx",
"args": ["optuna-mcp"]
}
}
}
Add --storage arguments if you need persistent storage.create_study, ask, tell, or plot_optimization_history.ask), report results (tell), manage user attributes.--storage <SQLALCHEMY_URL> when starting the server.A Model Context Protocol (MCP) server that automates optimization and analysis using Optuna.
The Optuna MCP Server can be used in the following use cases, for example.
For details, see the Examples section.
The Optuna MCP server can be installed using uv or Docker.
This section explains how to install the Optuna MCP server, using Claude Desktop as an example MCP client.
Before starting the installation process, install uv from Astral.
Then, add the Optuna MCP server configuration to the MCP client.
To include it in Claude Desktop, go to Claude > Settings > Developer > Edit Config > claude_desktop_config.json
and add the following:
{
"mcpServers": {
"Optuna": {
"command": "uvx",
"args": [
"optuna-mcp"
]
}
}
}
Additionally, you can specify the Optuna storage with the --storage argument to persist the results.
{
"mcpServers": {
"Optuna": {
"command": "uvx",
"args": [
"optuna-mcp"
"--storage",
"sqlite:///optuna.db"
]
}
}
}
After adding this, please restart Claude Desktop application. For more information about Claude Desktop, check out the quickstart page.
You can also run the Optuna MCP server using Docker. Make sure you have Docker installed and running on your machine.
{
"mcpServers": {
"Optuna": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--net=host",
"-v",
"/PATH/TO/LOCAL/DIRECTORY/WHICH/INCLUDES/DB/FILE:/app/workspace",
"optuna/optuna-mcp:latest",
"--storage",
"sqlite:////app/workspace/optuna.db"
]
}
}
}
The Optuna MCP provides the following tools. Specifically, it offers primitive functions of Optuna such as Study, Trial, Visualization, and Dashboard. Since MCP clients know the list of tools and the details of each tool, users do not need to remember those details.
study_name : name of the study (string, required).directions: The directions of optimization (list of literal strings minimize/maximize, optional).name : the name of the sampler (string, required).metric_names : The list of metric names for each objective (list of strings, required).search_space : the search space for Optuna (dictionary, required).trial_number : the trial number (integer, required).values : the result of the trial (float or list of floats, required).trial_number: the trial number (integer, required).key: the key of the user attribute (string, required).value: the value of the user attribute (any type, required).trial_number: the trial number (integer, required).target: index to specify which value to display (integer, optional).target_name: target’s name to display on the axis label (string, optional).reference_point : a list of reference points to calculate the hypervolume (list of floats, required).target_names: objective name list used as the axis titles (list of strings, optional).include_dominated_trials: a flag to include all dominated trial's objective values (boolean, optional).targets: a list of indices to specify the objective values to display. (list of integers, optional).params : parameter list to visualize (list of strings, optional).target : an index to specify the value to display (integer, required).target_name : target’s name to display on the color bar (string, required).params : parameter list to visualize (list of strings, optional).target : an index to specify the value to display (integer, required).target_name : target’s name to display on the axis label and the legend (string, required).params : parameter list to visualize (list of strings, optional).target : an index to specify the value to display (integer, required).target_name : target’s name to display on the axis label (string, required).params : parameter list to visualize (list of strings, optional).target : an index to specify the value to display (integer/null, optional).target_name : target’s name to display on the legend (string, required).target : an index to specify the value to display (integer, required).target_name : target’s name to display on the axis label (string, required).params : parameter list to visualize (list of strings, optional).target : an index to specify the value to display (integer, required).target_name : target’s name to display on the color bar (string, required).port: server port (integer, optional, default: 58080).Here we present a simple example of optimizing the 2D-Sphere function, along with example prompts and the summary of the LLM responses.
| User prompt | Output in Claude |
|---|---|
| (Launch Claude Desktop) | |
| Please create an Optuna study named "Optimize-2D-Sphere" for minimization. | |
| Please suggest two float parameters x, y in [-1, 1]. | |
| Please report the objective value x**2 + y**2. To calculate the value, please use the JavaScript interpreter and do not round the values. | |
| Please suggest another parameter set and evaluate it. | |
| Please plot the optimization history so far. |
You can also start the Optuna dashboard via the MCP server to analyze the optimization results interactively.
| User prompt | Output in Claude |
|---|---|
| Please launch the Optuna dashboard. |
By default, the Optuna dashboard will be launched on port 58080.
You can access it by navigating to http://localhost:58080 in your web browser as shown below:
Optuna dashboard provides various visualizations to analyze the optimization results, such as optimization history, parameter importances, and more.

This demo showcases how to use the Optuna MCP server to automatically find optimal FFmpeg encoding parameters. It optimizes x264 encoding options to maximize video quality (measured by the SSIM score) while keeping encoding time reasonable.
Check out examples/ffmpeg for details.

In this example, we will optimize a cookie recipe, referencing the paper titled "Bayesian Optimization for a Better Dessert".
Check out examples/cookie-recipe for details.
This example optimizes a Matplotlib configuration.
Check out examples/auto-matplotlib for details.
MIT License (see LICENSE).
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.