Use from an agent
An AI agent can use Goldilocks to inspect structures and prepare Quantum ESPRESSO inputs. Pick the interface that fits your agent:
| Your agent | Use |
|---|---|
| Has a shell, such as a coding agent | The CLI, with --json (CLI reference) |
| An MCP host that starts local servers, such as a desktop app | MCP over stdio |
| A hosted agent that connects over the network | MCP over streamable HTTP |
| A service or a script | The HTTP API |
All of them give the same answers as the CLI and the Workbench.
Install Goldilocks and its assets on the machine that runs the server. A request never installs anything.
pip install "goldilocks-core[mcp,http]"
goldilocks assets install all
Install all, so the server can serve every functional and spin-orbit
coupling; GET /ready reports ready only when every asset of all is
installed. A table the server lacks makes explain and run refuse the
request.
MCP
goldilocks serve mcp
| Tool | What it does |
|---|---|
capabilities |
Codes, tasks, settings, tables, HPC profiles, models and warnings. Pass task to get only that task's settings |
inspect_structure |
Parse a structure and report its composition, lattice and sites |
magnetic_orderings |
List candidate magnetic orderings. rank_with_mmace ranks them, reporting progress |
explain |
Every decision for a task, and what run would refuse, without generating files |
run |
Generate the inputs. It returns the file names, decisions and warnings, not the file contents |
Arguments are flat: {"structure_content": "<CIF text>", "task": "band"}.
structure_content is the text of a CIF or POSCAR file, never a path. Each
tool publishes its input and output schema.
A refused call returns a tool error whose content is
{"error": {"kind", "message", "details"}}, as over HTTP. When run
refuses, kind is advice_incomplete and details.findings lists the
causes, each with remedies.
Connect a host
For Claude Code:
claude mcp add goldilocks-core -- goldilocks serve mcp --publish-root /absolute/path/to/runs
Most other hosts read an mcpServers block from a JSON config file (Claude
Desktop: claude_desktop_config.json; Cursor: ~/.cursor/mcp.json; Gemini
CLI: ~/.gemini/settings.json):
{
"mcpServers": {
"goldilocks-core": {
"command": "goldilocks",
"args": ["serve", "mcp", "--publish-root", "/absolute/path/to/runs"]
}
}
}
Codex reads ~/.codex/config.toml:
[mcp_servers.goldilocks-core]
command = "goldilocks"
args = ["serve", "mcp", "--publish-root", "/absolute/path/to/runs"]
startup_timeout_sec = 60
tool_timeout_sec = 600
- The publish root must already exist (
mkdir -p /absolute/path/to/runs); otherwise the server refuses to start and the host only shows a failed connection. - If the host cannot find
goldilocks, give its full path (which goldilocks), or letuvxfetch it:"command": "uvx","args": ["--from", "goldilocks-core[mcp]", "goldilocks", "serve", "mcp"]. Run that command once in a terminal first: the first start can download several GB, longer than a host waits for a server to start. - Add an
envblock only for the environment variables you need, such as"env": {"GOLDILOCKS_MMACE_DEVICE": "cuda"}, orGOLDILOCKS_ASSET_ROOTif the assets are not in the default place. - A ranking with
rank_with_mmacecan take minutes; give the host a long tool timeout where it has one, astool_timeout_secabove does for Codex.
Let run write files
Without --publish-root, run writes nothing. With it, run takes a
bundle_name (letters, digits, ., _, -) and writes the whole bundle,
the same files as goldilocks run --out, to <publish root>/<bundle_name>.
A name already used is refused with bundle_exists; nothing is overwritten.
Give an absolute path to an existing directory the server can write to:
desktop hosts often start servers in /.
Remote MCP
For an agent that connects over the network:
goldilocks serve mcp --transport streamable-http
The endpoint is http://127.0.0.1:8001/mcp; --host and --port change it.
It has no authentication:
- keep the local host, or put an authenticated reverse proxy in front. On a
local host the server accepts only a local
Hostheader with its port, such as127.0.0.1:8001, so the proxy must send that; - run one server process, since sessions live in memory;
- give the proxy a long read timeout: a ranking keeps its call open for minutes;
- do not combine
--publish-rootwith a non-local host unless the proxy checks who calls. The bundle lands on the server's disk, not the caller's.
HTTP API
goldilocks serve http
The server listens on http://127.0.0.1:8000 and also serves the Workbench.
| Route | What it does |
|---|---|
GET /capabilities |
Codes, tasks, settings, tables, HPC profiles, models and warnings; ?task= keeps one task's settings |
POST /inspect |
Parse a structure |
POST /explain |
Every decision, plus blocking: what /run would refuse |
POST /run |
Generate the inputs. respond_with: "json" (default) returns a summary; "archive" returns the bundle as a ZIP file |
POST /magnetic-orderings |
Candidate magnetic orderings, unranked |
POST /magnetic-orderings/rank |
Queue a ranking of the candidates; 202 with the job |
GET /magnetic-orderings/rank/{job_id} |
The ranking job's state |
DELETE /magnetic-orderings/rank/{job_id} |
Cancel the ranking job |
GET /health |
The process is up |
GET /ready |
Every asset of the all profile is installed and intact; otherwise 503, kind assets_unavailable |
The full schema is at /openapi.json on a running server, with interactive
documentation at /docs. This site publishes the schema of the version on
the main branch, which it documents, at
stfc.github.io/goldilocks-core/openapi.json.
A request body looks like this:
{
"structure_content": "data_Si\n...",
"structure_name": "Si.cif",
"task": "band",
"overrides": {"k_path_distance": 0.05}
}
structure_nameis a file name, without directories. Its.cifor.poscarsuffix sets the format unless you givestructure_format.overridestakes the same keys as--set.- Unknown fields are refused.
Errors
Every failure has the body {"error": {"kind", "message", "details"}}.
| Status | Kinds |
|---|---|
| 422 | invalid_request (details.validation_errors), invalid_setting, invalid_structure, invalid_hpc_profile, advice_incomplete (details.findings), generation_error, submission_error |
| 424 | asset_corrupt: repair it on the server with goldilocks assets install |
| 404 | unknown_ranking |
| 500 | A failure on the server, such as pseudo_import_error |
message is written to show the user. details appears when there is more
to report, such as validation errors or findings. When /run refuses with
advice_incomplete, each finding in details.findings has a code, a
message and remedies: override patches that each fix it.
A pseudopotential table that is not installed on the server is such a refusal: a finding names the table, with no remedy a request can apply. Install it on the server.
Ranking jobs
A ranking takes seconds to minutes, and the server runs one at a time.
POST /magnetic-orderings/rankwith the same body as/magnetic-orderings. It returns at once withjob_id,stateandposition.- Poll
GET /magnetic-orderings/rank/{job_id}at least every 120 s; a job nobody polls is dropped.stateisqueued(withposition),running(withprogress:doneoftotal),done(withreport, the ranked listing) orfailed(witherror). DELETEthe job to cancel it.
Jobs live in the server's memory, so run one server process. A job the server no longer holds is a 404.
Security
The HTTP server has no authentication. Keep the default local address, or put it behind a firewall or an authenticated reverse proxy that also handles TLS.
Requests carry structures as text and name registered tables. They cannot
read server paths, install assets, or write to the server's disk: /run
builds the bundle in memory.