Work with an AI assistant
DearDiary.run_mcp serves DearDiary over the Model Context Protocol, so an assistant such as Claude Code can read and manage your experiments: compare runs, log results, store reports, and register models. Everything the tracking API does is available.
The server comes from an optional dependency. Add it to the environment that has DearDiary:
using Pkg
Pkg.add("ModelContextProtocol")Tools
| Area | Tools |
|---|---|
| Session | whoami |
| Projects | list_projects, get_project, create_project, update_project, delete_project |
| Experiments | list_experiments, get_experiment, create_experiment, update_experiment, delete_experiment |
| Iterations | list_iterations, get_iteration, get_environment, create_iteration, update_iteration, delete_iteration, compare_iterations |
| Parameters | list_parameters, log_parameters, update_parameter, delete_parameter |
| Metrics | list_metrics, get_metric_history, log_metrics, update_metric, delete_metric |
| Artifacts | list_artifacts, read_artifact, create_artifact, update_artifact, delete_artifact |
| Tags | list_tags, add_tag, delete_tag |
| Model registry | list_models, create_model, update_model, delete_model, register_model_version, update_model_version, delete_model_version |
| Users | list_users, create_user, update_user, delete_user |
| Permissions | list_permissions, grant_permission, update_permission, revoke_permission |
Every tool carries the standard MCP annotations: reading tools are marked read-only, and tools that change or delete records are marked destructive, so clients can ask before running them. The same rules apply as everywhere else in DearDiary: an ended iteration is locked, a record a model version still uses can't be deleted, and deleting a project or experiment removes everything under it.
A few tools fill in what the API leaves to the caller. Setting an iteration to SUCCEEDED, FAILED, or KILLED ends it, and setting an experiment to STOPPED or FINISHED records its end date. A metric's final value is the one logged at its highest step. read_artifact returns text as is and other content as base64, and create_artifact takes either.
Resources and prompts
The server also publishes the records as resources, so a client can attach them to a conversation:
| URI | Content |
|---|---|
deardiary://projects | Every project the connection can read. |
deardiary://project/{project_id} | A project with its tags, experiments, and models. |
deardiary://project/{project_id}/models | A project's models and their versions. |
deardiary://experiment/{experiment_id} | An experiment with its tags and artifacts. |
deardiary://experiment/{experiment_id}/iterations | An experiment's iterations with parameters and final metrics. |
deardiary://iteration/{iteration_id} | An iteration with its metric summary. |
deardiary://iteration/{iteration_id}/metrics/{key} | One metric's history. |
deardiary://iteration/{iteration_id}/Project.toml | The Project.toml the iteration ran with. |
deardiary://iteration/{iteration_id}/Manifest.toml | The Manifest.toml the iteration ran with. |
deardiary://artifact/{artifact_id} | An artifact's stored content. |
Four prompts start common analyses: analyze_experiment, diagnose_iteration, compare_iterations, and register_best_iteration. The last one asks before promoting anything to PRODUCTION.
Use a local database
Point the server at a database file. Each tool call opens the file and closes it right after:
claude mcp add deardiary -- julia --project=/path/to/env -e \
'using DearDiary, ModelContextProtocol; DearDiary.run_mcp(; file_name="/path/to/deardiary.db")'A local database has no accounts, so the tools act as the default administrator. DuckDB lets one process at a time open a database file: a call fails while a training script has the file open, and the script can't open it during a call. The tool error says so. To work with runs while they train, use a server.
Use a running server
Pass the server's URL to go through the REST API instead. The tools then act as the signed-in user, with that user's permissions, and runs can be read while they train. Keep the credentials in environment variables rather than in the command:
claude mcp add deardiary \
-e DEARDIARY_USERNAME=alice -e DEARDIARY_PASSWORD=secret -- \
julia --project=/path/to/env -e 'using DearDiary, ModelContextProtocol;
DearDiary.run_mcp("http://server.example:9000";
username=ENV["DEARDIARY_USERNAME"], password=ENV["DEARDIARY_PASSWORD"])'With a username and password, the server signs in again when its token expires. Pass token instead to use an already-issued token, which stops working when it expires. Leave all three out when the server runs with authentication disabled.
Other clients and HTTP
Other MCP clients take the same command. Claude Desktop, for example, reads it from claude_desktop_config.json:
{
"mcpServers": {
"deardiary": {
"command": "julia",
"args": [
"--project=/path/to/env",
"-e",
"using DearDiary, ModelContextProtocol; DearDiary.run_mcp(; file_name=\"/path/to/deardiary.db\")"
]
}
}
}Pass port to serve Streamable HTTP instead of stdio, for clients that connect to a running server:
using DearDiary, ModelContextProtocol
DearDiary.run_mcp(; file_name="deardiary.db", port=3000)claude mcp add --transport http deardiary http://127.0.0.1:3000/The HTTP server only listens on 127.0.0.1 and refuses requests from other hosts, since it has no authentication of its own. To share access across machines, run a DearDiary server and point each assistant's run_mcp at its URL.
ModelContextProtocol.jl also exports a function named connect. In a session that loads both packages, call DearDiary.connect by its full name.