Skip to main content

CLI and local MCP server for the OpenCosmo platform

Project description

OpenCosmo Portal CLI (ocp)

Command-line interface and local MCP server for the OpenCosmo platform. Query cosmological simulation datasets at DOE Leadership Computing Facilities from your terminal.

Installation

pip install opencosmo-portal

Or for development:

cd cli
uv sync

Quick Start

The default profile points to http://localhost:8000 (local development). For development against a local backend:

# Authenticate via browser (Globus OAuth)
ocp auth login

# Browse available tasks
ocp task list
ocp task info <slug>

# Submit a task and monitor the run
ocp task run <slug>
ocp run status <run-id> --watch
ocp run results <run-id>

Commands

ocp auth — Authentication

Command Description
ocp auth login Authenticate via browser (Globus OAuth)
ocp auth logout Clear stored tokens
ocp auth status Show token status and expiry

ocp config — Profile Management

Command Description
ocp config list List all profiles
ocp config add-profile <name> <url> Add or update a profile
ocp config set-profile <name> Set default profile
ocp config remove-profile <name> Delete a profile
ocp config show [name] Show profile details

ocp task — Tasks

Command Description
ocp task list List available tasks
ocp task info <slug> Show task details and input parameters
ocp task run <slug> Submit a task (interactive or --input)

ocp run — Runs

Command Description
ocp run list List your runs
ocp run status <id> [--watch] Check run status
ocp run logs <id> View run logs
ocp run results <id> Download results
ocp run cancel <id> Cancel a run
ocp run archive <id> Archive a run

ocp admin tasks install — Adapter Installation

Install task adapter definitions into the backend database. Discovery is explicit and non-recursive: directory mode uses the directory argument directly, while archive modes require --subdir; only direct child *.json files in that selected directory are loaded.

ocp admin tasks install dir ./artifact/build/portal_v2
ocp admin tasks install dir ./artifact/build/portal_v2 --dry-run

OPENCOSMO_API_URL=https://portal.example.org \
OPENCOSMO_API_KEY="$OPENCOSMO_API_KEY" \
ocp admin tasks install dir build/portal_v2

ocp admin tasks install url "https://.../artifacts/download?file_type=archive" \
  --subdir build/portal_v2 \
  --header "PRIVATE-TOKEN:${GITLAB_TOKEN}"

ocp admin tasks install gitlab \
  --host https://git.cels.anl.gov \
  --project hacc/hacc-compute-portal \
  --ref master \
  --job adapter-build \
  --subdir build/portal_v2 \
  --gitlab-token-env GITLAB_TOKEN

Supported archives are .zip, .tar, .tar.gz, and .tgz. Protected URL tokens are accepted through explicit token/header options or environment variables and are not persisted by the CLI or backend.

For CI, provide an admin API key through OPENCOSMO_API_KEY and set OPENCOSMO_API_URL to the target portal. The CLI automatically exchanges the API key for a JWT, uses that JWT for backend requests, and does not persist the API key or env-derived JWT. OPENCOSMO_API_KEY takes precedence over stored profile tokens.

For non-dry-run installs, the CLI first sends a dry-run request for every discovered task. If any prevalidation request fails, no real install requests are sent. Once real installation starts, requests are committed one task at a time.

ocp whoami — User

Show current user info.

ocp mcp — MCP Server

Start a local stdio MCP server for AI assistants like Claude Desktop.

ocp mcp start

Configure in Claude Desktop (claude_desktop_config.json):

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

Global Options

Option Description
--profile, -p Use a specific profile
--format, -f Output format: table (default) or json
--version Show version
--help Show help for any command

Releasing

The CLI is published to PyPI as opencosmo-portal via GitHub Actions (trusted publisher / OIDC).

Automated (recommended)

Use the Release CLI workflow in GitHub Actions:

  1. Go to Actions → Release CLI → Run workflow
  2. Select the bump type (patch, minor, or major)
  3. The workflow bumps cli/pyproject.toml, commits, tags, and pushes — which triggers the publish workflow automatically

Manual

  1. Bump version in cli/pyproject.toml (or run cd cli && uv version --bump patch)
  2. Commit: git commit -am "release: CLI v0.2.0"
  3. Tag: git tag cli-v0.2.0
  4. Push both: git push origin main cli-v0.2.0

The publish-cli.yml workflow will:

  • Run the full test suite
  • Verify the tag version matches pyproject.toml
  • Build and publish to PyPI

First-time setup

Register a trusted publisher on pypi.org:

Field Value
Package name opencosmo-portal
Owner ArgonneCPAC
Repository OpenCosmoPortal
Workflow publish-cli.yml
Environment pypi

Then create a pypi environment in GitHub repo settings → Environments.

Configuration

Config and tokens are stored in ~/.opencosmo/:

~/.opencosmo/
├── config.json          # Profiles (name → API URL)
└── tokens/
    └── <profile>.json   # OAuth tokens per profile

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencosmo_portal-0.3.0.tar.gz (137.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencosmo_portal-0.3.0-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file opencosmo_portal-0.3.0.tar.gz.

File metadata

  • Download URL: opencosmo_portal-0.3.0.tar.gz
  • Upload date:
  • Size: 137.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opencosmo_portal-0.3.0.tar.gz
Algorithm Hash digest
SHA256 253f193ce02f04c8c9864770adbec4c5ff565edf3ee52f063bcde03c0c807cec
MD5 5d489d2a78bc13b59a965f155d6db274
BLAKE2b-256 9d4d6651e1e8fac450bdd8bc4c2dc976e977b5751b65bf7532ea69196e4552f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencosmo_portal-0.3.0.tar.gz:

Publisher: publish-cli.yml on ArgonneCPAC/OpenCosmoPortal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opencosmo_portal-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opencosmo_portal-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48226363234303d6907cc5ee94bc3d51db5258767715f54e5b82865f166b81e7
MD5 ce3f40dc766b40cb1cddbd9af6543dc8
BLAKE2b-256 f20130f5f8a372d785a921c2c1c3d68f50088f2ead1bc463fc78b6f561fe61e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencosmo_portal-0.3.0-py3-none-any.whl:

Publisher: publish-cli.yml on ArgonneCPAC/OpenCosmoPortal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page