Skip to main content
Glama

set_trial_user_attr

Assign user-defined attributes to specific trials for tracking custom metadata during hyperparameter optimization in Optuna MCP Server.

Instructions

Set user attributes for a trial

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes
trial_numberYes
valueYes

Implementation Reference

  • The main handler function for the 'set_trial_user_attr' tool. It retrieves the trial ID from the study's storage and calls storage.set_trial_user_attr to set the user attribute for the specified trial.
    @mcp.tool(structured_output=True) def set_trial_user_attr(trial_number: int, key: str, value: typing.Any) -> str: """Set user attributes for a trial""" if mcp.study is None: raise McpError( ErrorData( code=INTERNAL_ERROR, message="No study has been created. Please create a study first.", ) ) storage = mcp.study._storage trial_id = storage.get_trial_id_from_study_id_trial_number( mcp.study._study_id, trial_number ) storage.set_trial_user_attr(trial_id, key, value) return f"User attribute {key} set to {json.dumps(value)} for trial {trial_number}"

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