Skip to main content

OpenCosmo Portal CLI (ocp)

Command-line client and local MCP server for the OpenCosmo Portal: query cosmological simulation datasets at DOE Leadership Computing Facilities from your terminal or from an AI assistant.

pip install opencosmo-portal      # in a checkout: cd cli && uv sync, then prefix commands with `uv run`

Quick start

ocp auth login                    # Globus device-code flow; --browser for a local redirect flow
ocp task list
ocp task info <slug>
ocp task run <slug>               # interactive; or --input/--file JSON
ocp run status <run-id> --watch
ocp run results <run-id>

Shipped profiles: production (https://cosmoexplorer.alcf.anl.gov, default), staging (https://opencosmo-test.cels.anl.gov, internal network), dev (http://localhost:8000). Pass --profile <name> or set a default with ocp config set-profile. Shipped profiles cannot be removed but their URLs can be overridden with ocp config add-profile; former official URLs migrate automatically on upgrade, overrides are kept.

Config and tokens live in ~/.opencosmo/ (config.json, tokens/<profile>.json). Output is table or --format json. After interactive commands the CLI checks PyPI for a newer release at most once per 24 h and shows active portal announcements (outages, new features, deprecations) cached for 5 minutes per portal — both stderr-only, bounded by a shared one-second deadline, and never affecting the command. OPENCOSMO_DISABLE_UPDATE_CHECK=1 and OPENCOSMO_DISABLE_ANNOUNCEMENTS=1 turn them off. ocp announcements lists active announcements on demand.

Commands

ocp --help and ocp <group> --help list everything. Overview:

Group Commands
ocp auth login, logout, status (refreshes unless --no-refresh), consent (grant flow authorizations some tasks need)
ocp config list, show, add-profile, set-profile, remove-profile
ocp task list, info <slug>, run <slug>
ocp run list, status <id> [--watch], logs, results, cancel, archive
ocp docs Browse portal documentation
ocp whoami Current user
ocp announcements Active portal announcements
ocp mcp start — local stdio MCP server
ocp admin tasks, datasets, docs, announcements, service-accounts, users, runs, audit-logs, stats

Interactive ocp task run shows leaf fields of the task's nested input as a numbered table with their currently active constraints, re-evaluates the schema's conditional rules after every edit (repairing or flagging values that became invalid), and validates the complete input against the task schema before submitting. --input/--file payloads are validated as supplied, with no repair. ocp task info lists parameters by dotted path (filters.sod_halo_mass.minval), matching the nested JSON those options take.

ocp run status renders the server's run-diagnostics projection (failure code and phase, guidance, warnings, bounded traceback, evidence state, correlation IDs); against an older server it falls back to the summary view.

MCP server for AI assistants

ocp mcp start

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": { "opencosmo": { "command": "ocp", "args": ["mcp", "start"] } }
}

This stdio server supports both legacy and modern MCP handshakes and calls the portal API with the profile's CLI token. It is distinct from the hosted remote endpoint at <portal-origin>/mcp, which is modern-protocol-only and has its own OAuth token; ocp auth logout does not clear a remote MCP client's token.

The server offers one run_<task> tool per task, loaded when it starts. If that fails, for example because the portal is unreachable or the login has expired, the server retries on each later tool request and tells the client that its tool list changed once the tasks load, so no restart is needed.

For an unattended setup, set OPENCOSMO_API_KEY in the server's environment (the "env" object of the mcpServers entry). The server then exchanges the key for a short-lived token, exchanges it again when that token expires, and needs no ocp auth login or token file. Without the variable it uses the stored login.

Administration

All ocp admin commands require admin permissions. For CI, set OPENCOSMO_API_URL and OPENCOSMO_API_KEY (a service-account key); the CLI exchanges the key for a JWT per run and persists neither. OPENCOSMO_API_KEY takes precedence over stored profile tokens.

Content deployment — categories, datasets, task adapters, and user docs are complete desired-state payloads. Each command accepts dir <path>, url <archive-url> --subdir <dir> (--header "PRIVATE-TOKEN:..."), or gitlab --host --project --ref --job --subdir [--gitlab-token-env]; archives may be .zip, .tar, .tar.gz, .tgz. Discovery is non-recursive: only direct children of the selected directory are read (for tasks, *.json; for docs, Markdown at the root plus one subdirectory level, root index.md required — pass the directory containing index.md inside a docs checkout or extracted artifact, not the checkout root). Deploy in this order:

ocp admin tasks categories sync build/categories.json --yes
ocp admin datasets sync build/datasets.json --yes
ocp admin tasks install dir build/tasks --strict
ocp admin docs deploy dir <docs-checkout>/content/documentation --yes

Every command dry-runs server-side first and shows the planned create/update/delete actions; without --yes it asks for confirmation (defaulting to no when anything would be deleted). tasks install --strict exits 1 on any warning (for example an unregistered category slug) before sending real installs; installs are idempotent, so re-running after fixing the registry is safe. Dataset sync validates binding tags, so task installs fail on a fresh instance until datasets are synced; deleting a dataset that installed tasks still reference warns rather than fails.

Service accounts:

ocp admin service-accounts create ci-task-manager --profile task-manager --description "CI"
ocp admin service-accounts rotate-key ci-task-manager      # create/rotate print the key once
ocp admin service-accounts revoke-key ci-task-manager KEY_ID --yes
ocp admin service-accounts disable ci-task-manager --yes

Enabled service accounts are valid through urn:opencosmo:service-account; the task-manager profile additionally needs urn:opencosmo:service-account:task-manager in the backend's AUTH_ADMINS.

Releasing

Run the Release workflow in GitHub Actions with component=cli (or all for a major bump); the resulting cli-v* tag triggers publish-cli.yml, which tests, verifies the tag matches pyproject.toml, and publishes to PyPI via trusted publishing. No manual tagging.

Metadata

Release files for opencosmo-portal 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencosmo-portal 1.3.1
File Size Uploaded Provenance Actions
opencosmo_portal-1.3.1.tar.gz 262.5 kB With provenance Details for opencosmo_portal-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opencosmo-portal 1.3.1
File Interpreter ABI Platform Actions
opencosmo_portal-1.3.1-py3-none-any.whl Python 3 none any Details for opencosmo_portal-1.3.1-py3-none-any.whl

Total release size: 376.2 kB

Release files / opencosmo_portal-1.3.1.tar.gz

Download URL opencosmo_portal-1.3.1.tar.gz
Size 262.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6fac0478512b2e8084f29593bec158b1023de6d65b389871f3d35cfb334a23d7
BLAKE2b-256 checksum
How to use checksums
8de50eb52c1f3265b079a826045cd2f800b2397d2ead8879b1d7f8db05acad45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / opencosmo_portal-1.3.1-py3-none-any.whl

Download URL opencosmo_portal-1.3.1-py3-none-any.whl
Size 113.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
331dba7d7961c0f3b5a2c5561bb3b44e6b361d505aaeb5456c029d25e1332a46
BLAKE2b-256 checksum
How to use checksums
3f5dd3f6b5d31ce5ddb2e29a75c3c250ca66e6c2606fde3d0e0511a7817a878b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for opencosmo-portal 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opencosmo_portal-1.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page