Metadata-Version: 2.5
Name: mlpal-cli
Version: 0.9.4
Summary: Command-line interface for managing MLpal platform resources
Project-URL: Homepage, https://mlpal.ai
Author-email: MLPal <contact@mlpal.ai>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: click>=8.1.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: keyring>=25.0.0
Requires-Dist: keyrings-alt>=5.0.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: python-frontmatter>=1.1.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.12.0
Requires-Dist: websockets>=14.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Description-Content-Type: text/markdown

# MLpal CLI

Command-line interface for managing MLpal platform resources.

## Features

- **Authentication**: Cognito-based login with automatic token refresh
- **MLpal Assistants**: Access the unified AI gateway (models, API keys, usage)
- **Static Agents**: Manage domain-specific workflow agents
- **HOPs**: Browse the platform HOP catalog, use or register HOPs personally or in an org, and manage HOP keys
- **MCP Servers**: Build, deploy, and manage MCP servers with pool pods
- **Skills**: Author, publish, search, and install MLpal skills
- **Plugins**: Install, sync, and publish MLpal plugins (skills + MCP pins + hooks) into Claude Code
- **Projects**: Organize your agents into projects
- **Organizations**: Manage team members and invitations
- **Multiple Profiles**: Switch between different accounts/environments

## Requirements

- Python 3.11+

## Installation

```bash
# Using uv (recommended)
uv tool install mlpal-cli --index-url $MLPAL_PYPI_URL/simple/

# Using pip
pip install mlpal-cli --index-url $MLPAL_PYPI_URL/simple/
```

## Quick Start

```bash
# Login with your email and password
mlpal login

# Check authentication
mlpal whoami

# List available models
mlpal gateway models list

# Create an API key for the AI gateway
mlpal gateway keys create --name "my-key"

# Deploy an MCP server
mlpal mcp create --name my_search_mcp --category search
mlpal mcp deploy 8 --source ./my-server/
```

## Commands

### Authentication

```bash
mlpal login              # Login in the browser (--password for email/password)
mlpal logout             # Logout
mlpal whoami             # Show current user
```

### MCP Servers

```bash
# CRUD
mlpal mcp create --name my_mcp --category search     # Create server (draft)
mlpal mcp list                                        # List your servers
mlpal mcp get 8                                       # Server details
mlpal mcp update 8 --auto-sleep 15 --compute-tier medium  # Update settings
mlpal mcp search "web search"                         # Search all servers

# Deploy & Lifecycle
mlpal mcp deploy 8 --source ./my-server/              # Deploy (instant from pool)
mlpal mcp stop 8                                      # Stop (pod returns to pool)
mlpal mcp start 8                                     # Start stopped server
mlpal mcp status 8                                    # Deployment status
mlpal mcp pull 8                                      # Download source code

# Scheduling
mlpal mcp schedule 8 --days weekdays --start 09:00 --end 18:00
mlpal mcp schedule 8 --add --days saturday --start 10:00 --end 14:00
mlpal mcp schedule 8 --days monday-friday --start 09:00 --end 18:00 --tz US/Pacific
mlpal mcp schedule 8 --clear

# Day formats: weekdays, weekends, everyday, mon-fri, monday-friday, mon,wed,fri

# Monitoring
mlpal mcp logs 8                                      # View logs
mlpal mcp metrics 8                                   # Per-tool metrics
mlpal mcp cost 8                                      # Compute cost

# Sharing & Keys
mlpal mcp keys create 8 --name "prod-key"             # Create API key
mlpal mcp keys list                                   # List keys
mlpal mcp keys revoke 42                              # Revoke key

# Templates
mlpal mcp templates                                   # List templates
```

### Plugins

A plugin bundles skills, MCP server pins, hooks, commands, and agents
into one installable unit, published to the mlpal registry and installed
into Claude Code via the local `mlpal` marketplace mirror
(`~/.claude/plugins/marketplaces/mlpal/`). See
[`docs/plugins.md`](docs/plugins.md) for the full reference (scopes,
lockfiles, MCP-pin drift rules, the `headersHelper` security model).

```bash
# Install / uninstall
mlpal plugins install acme/db-tools                   # latest, --scope project (default)
mlpal plugins install acme/db-tools@1.4.0 --scope user
mlpal plugins uninstall acme/db-tools

# Discover
mlpal plugins list                                    # what's installed at this scope
mlpal plugins outdated                                # installed vs. registry's latest
mlpal plugins update acme/db-tools                    # update one
mlpal plugins update --all                            # update every installed plugin

# Keep disk + Claude Code config converged to the lockfile
mlpal plugins sync                                    # re-mint MCP keys near expiry
mlpal plugins sync --verify                           # re-download bundles, check their hashes
mlpal plugins sync --verify --force                   # ... and accept a hash that no longer matches

# Author & publish
mlpal plugins validate .                              # check a local plugin dir, no network call
mlpal plugins publish . --version 1.0.0 --changelog "Initial release"
```

`--scope project|user|local` (default `project`) picks the lockfile
(`.claude/mlpal-plugins.lock.json`, `~/.claude/mlpal-plugins.lock.json`,
or `.claude/mlpal-plugins.local.lock.json`) and is passed through to
`claude plugin install <name>@mlpal --scope <scope>` for enablement — the
`claude` CLI must be on `PATH` to actually enable/disable a plugin in
Claude Code; without it, `install`/`uninstall`/`sync`/`update` still
complete the lockfile/disk side and print the manual `claude plugin ...`
commands to run (exit code 3). MCP server pins resolve to a
`headersHelper`-backed HTTP entry — the bearer key lives only in the CLI's
credential store (OS keyring / `0600` file fallback), never in a file
under the repo. Claude Code (not you) runs that helper at connect time,
so `mlpal` must also be on the `PATH` Claude Code itself starts with.

### Gateway (the unified AI gateway)

`mlpal assistants …` is the older name for the same commands and still works.

```bash
# Models
mlpal gateway models list          # List available models
mlpal gateway models get gpt-5.2   # Get model details

# API Keys
mlpal gateway keys create --name "my-key"  # Create API key
mlpal gateway keys list                    # List API keys
mlpal gateway keys revoke 123              # Revoke API key

# Usage & Health
mlpal gateway usage                # Get usage statistics
mlpal gateway health               # Health check
```

### Memory for your coding tools

```bash
mlpal memory connect claude-code      # or: codex
mlpal memory disconnect claude-code
mlpal memory keys list                # also: create, rotate, revoke <id>
```

`connect` gives a coding tool your MLPal memory at `https://memory.mlpal.ai/mcp`. A machine
has one memory key, which every tool on it uses: `connect` makes it the first time and never
prints it. The key can only read and write memory. It also prints a short block to add to
`CLAUDE.md` or `AGENTS.md`.

- **Claude Code** needs the `claude` command on PATH. Its config holds no key: it asks
  `mlpal memory headers` each time.
- **Codex** does the same from version 0.148.0. For an older Codex, `connect` writes the key
  to a private file and prints the `source` line to run.
- With the `mlpal-memory` plugin installed in either tool, the plugin brings the server and
  `connect` only makes the key.

One key for every tool means one tool cannot be cut off alone: `mlpal memory keys rotate`
replaces the key for all of them, and `mlpal memory keys revoke <id>` ends one.
`disconnect` removes a tool's entry and leaves the key (a key 0.9.3 made for that tool alone
is revoked). See [COMMANDS.md](COMMANDS.md) for
the rest of `mlpal memory`.

### Static Agents

```bash
# CRUD Operations
mlpal sa list                         # List static agents
mlpal sa create --name "Agent"        # Create static agent
mlpal sa get 123                      # Get agent details
mlpal sa update 123 --name "New Name" # Update agent
mlpal sa delete 123                   # Delete agent

# Lifecycle
mlpal sa deploy 123 --wait            # Deploy agent
mlpal sa stop 123                     # Stop agent
mlpal sa status 123                   # Get agent status
mlpal sa logs 123                     # View logs
mlpal sa logs 123 -f                  # Stream logs

# Sharing
mlpal sa share 123 --email user@x.com # Share agent
mlpal sa share 123 --list             # List shares
mlpal sa share 123 --email user@x.com --remove  # Remove share

# API Keys (for programmatic access)
mlpal sa keys create 123 --name "prod-key"  # Create API key
mlpal sa keys list 123                       # List keys
mlpal sa keys revoke 123 456                 # Revoke key
```

### HOPs

HOPs (harness operating profiles) are what yodex becomes for a job. Catalog
commands read the public platform catalog (no login). Registrations and keys
act in a scope: `--scope user` (personal, no org needed) or `--scope org:<id>`
(`--org-id N` is the same as `--scope org:N`); without either, your default
org, else your first org, else personal. Platform HOPs (coding, reviewer) are
MLPal's, like platform MCP servers: you use them, you do not register or edit
them. Keys minted under them belong to your scope; narrow what a key may do
with a custom key's policy.

```bash
# Platform catalog (hops.mlpal.ai)
mlpal hops search                     # All platform HOPs
mlpal hops search infra               # Search by name or description
mlpal hops show infra                 # Entry with its versions
mlpal hops show infra@0.3.1           # One version (sha256, size, changelog)
mlpal hops download infra --dir .     # Artifact .tar.gz, sha256-verified
mlpal hops get-started infra          # Make a catalog HOP usable in your scope
mlpal hops get-started coding --scope user   # Personal: coding is a platform HOP, no copy made

# Registrations
mlpal hops list --scope user          # Platform and User HOPs, keys, rung status
mlpal hops get 12                     # Requires, derived rungs, active keys
mlpal hops derive -r ./hop.yaml       # Dry run: what it would grant on each rung
mlpal hops register -n my-hop -v 0.1.0 -r ./hop.yaml   # Your own HOP from its requires block
mlpal hops update 12 -v 0.2.0 -r ./hop.yaml --enable agents:pr-triage   # Edit; keys follow
mlpal hops update 12 --allow-models 'claude-*' --deny-models claude-opus-5   # Model access (default: all)
mlpal hops update 12 --all-models    # Back to every model
mlpal hops delete 12                  # Delete (revokes its HOP keys)
mlpal hops metrics 12                 # What its keys spent across rungs
mlpal hops metrics 8 --owner org:6    # A platform HOP's spend by one scope's keys

# Keys (mlpal_hk_...): for a HOP, custom (your own policy), or admin (the scope's whole entitlement)
mlpal hops keys create 12 --label laptop   # HOP key; shown once, on a terminal (else --secret-file)
mlpal hops keys create 8 --label laptop --scope user   # Personal key under a platform HOP
mlpal hops keys compile --policy p.yaml    # Dry run a policy (list of statements)
mlpal hops keys create-custom --label ci --policy p.yaml
mlpal hops keys create-admin --label ops   # Everything the scope is entitled to
mlpal hops keys get 7                      # Kind, policy, bundle state (no secret)
mlpal hops keys update 7 --label ci-2 --policy p.yaml   # Policy: custom keys only
mlpal hops keys list --kind custom         # All keys in the scope, by kind (no secrets)
mlpal hops keys list --hop 12              # One HOP's keys
mlpal hops keys rotate 7                   # New bundle, same mlpal_hk_ string
mlpal hops keys revoke 7                   # Revoke the key and its bundle
```

### Projects

```bash
mlpal projects list                   # List projects
mlpal projects create --name "My Project"  # Create project
mlpal projects get 123                # Get project details
mlpal projects update 123 --name "New Name"  # Update project
mlpal projects delete 123             # Delete project
```

### Organization

```bash
mlpal org info                        # Organization info
mlpal org members                     # List members
mlpal org invite --email user@x.com   # Invite member
mlpal org invitations                 # List pending invitations
```

### Usage

```bash
mlpal usage summary                   # Usage summary
mlpal usage trends                    # Usage trends over time
mlpal usage export --output usage.csv # Export usage data
```

### Shared Resources

```bash
mlpal shared static-agents            # View shared agents
mlpal shared projects                 # View shared projects
```

## Output Formats

All commands support multiple output formats:

```bash
mlpal mcp list                    # Table (default)
mlpal mcp list -o json            # JSON
mlpal mcp list -o yaml            # YAML
mlpal mcp list -o text            # Plain text (IDs only)
```

## Profiles

Use profiles to manage multiple accounts or environments:

```bash
mlpal login --profile production
mlpal --profile production mcp list
MLPAL_PROFILE=production mlpal mcp list
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `MLPAL_PROFILE` | Active profile name |
| `MLPAL_BACKEND_URL` | Backend API URL |
| `MLPAL_ASSISTANTS_URL` | Assistants service URL |
| `MLPAL_SKILLS_URL` | Skills/plugins registry URL |
| `MLPAL_MCP_URL` | MCP registry + gateway URL (also used to resolve plugin MCP pins) |
| `MLPAL_AUTH_URL` | Auth service URL (plugin MCP key revocation) |

## Development

```bash
# Clone the repository
git clone https://github.com/mlpal/mlpal-cli.git
cd mlpal-cli

# Install dependencies
uv sync

# Run tests
uv run pytest

# Run the CLI locally
uv run mlpal --help
```

## Releasing

Publishing is tag-triggered. Neither a push to `main` nor a pull request publishes anything;
pull requests run the test suite (`.github/workflows/test.yml`).

1. Bump `version` in `pyproject.toml` and `__version__` in `src/mlpal_cli/__init__.py` to the
   same value, and merge to `main`.
2. Tag that commit on `main` and push the tag:
   ```bash
   git tag vX.Y.Z <commit-on-main>
   git push origin vX.Y.Z
   ```
3. `.github/workflows/release.yml` checks that the tag equals the pyproject version and points
   at `main`, runs the tests, builds the wheel and sdist, and installs the wheel in a clean
   environment. It then publishes the same files to both indexes:
   - **pypi.org**, through Trusted Publishing (no stored token), from the `pypi` environment;
   - **pypi.mlpal.ai**, the mirror kept during the transition.

Versions are immutable on both indexes. A version that is already published fails the release;
bump the version and tag again.

## License

Apache-2.0. See [LICENSE](LICENSE).
