Skip to main content
Glama

best_trials

Identify optimal trials at the Pareto front in Optuna studies for efficient hyperparameter optimization and result analysis through the MCP server.

Instructions

Return trials located at the Pareto front in the study.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'best_trials' tool. It returns the best trials (Pareto front) from the Optuna study as a list of TrialResponse objects. Registered via @mcp.tool decorator.
    @mcp.tool(structured_output=True) def best_trials() -> list[TrialResponse]: """Return trials located at the Pareto front in the study.""" if mcp.study is None: raise McpError( ErrorData( code=INTERNAL_ERROR, message="No study has been created. Please create a study first.", ) ) return [ TrialResponse( trial_number=trial.number, params=trial.params, values=trial.values, user_attrs=trial.user_attrs, system_attrs=trial.system_attrs, ) for trial in mcp.study.best_trials ]
  • Pydantic BaseModel defining the output schema for individual trials returned by the best_trials tool.
    class TrialResponse(BaseModel): trial_number: int params: dict[str, typing.Any] | None = Field( default=None, description="The parameter values suggested by the trial." ) values: list[float] | None = Field( default=None, description="The objective values of the trial." ) user_attrs: dict[str, typing.Any] | None = Field( default=None, description="User-defined attributes for the trial." ) system_attrs: dict[str, typing.Any] | None = Field( default=None, description="System-defined attributes for the trial." )
  • The register_tools function is called here, which defines and registers all tools including best_trials via decorators.
    mcp = register_tools(mcp)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/optuna/optuna-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server