Aller au contenu principal

CLI Reference (stoactl)

stoactl is a kubectl-style CLI for managing STOA Platform resources. It provides API deployment, project scaffolding, API-to-MCP bridging, diagnostics, and resource management.

Installation

brew install stoa-platform/tap/stoactl

Quick Reference

CommandDescription
stoactl deployDeploy an API from a stoa.yaml file
stoactl logsShow deployment history for an API
stoactl initInitialize a new STOA project
stoactl bridgeConvert OpenAPI spec to MCP Tool CRDs
stoactl doctorRun diagnostic checks
stoactl applyCreate or update a resource from a YAML file
stoactl getList resources (apis, deployments, tools)
stoactl deleteDelete a resource
stoactl authAuthentication commands
stoactl configManage CLI contexts
stoactl token-usageView API token usage statistics
stoactl versionPrint version information

Deployment Commands

stoactl deploy

Deploy an API to a target environment from a stoa.yaml file, or use sub-commands to manage deployments imperatively.

stoactl deploy [stoa.yaml] [flags]
stoactl deploy <subcommand>

File-based deploy (recommended):

stoactl deploy ./stoa.yaml --env production
stoactl deploy ./api.yaml --env dev --watch

Flags (file-based deploy):

FlagDefaultDescription
--envTarget environment: dev, staging, production (required)
--watch, -wfalsePoll deployment status until completion (success or failure)
--output, -otableOutput format: table, wide, yaml, json

stoactl deploy create

Create a deployment imperatively (without a stoa.yaml file).

stoactl deploy create --api-id <id> --env <env> --version <version> [flags]

Flags:

FlagRequiredDescription
--api-idYesAPI ID to deploy
--envYesTarget environment
--versionYesVersion to deploy (e.g. 2.0.0)
--gatewayNoTarget gateway ID
--commitNoGit commit SHA (for traceability)
--watch, -wNoWatch deployment until completion

Example:

stoactl deploy create --api-id customer-api --env production --version 2.0.0 --watch

stoactl deploy list

List recent deployments with optional filters.

stoactl deploy list [flags]
stoactl deploy ls [flags]

Flags:

FlagDescription
--api-idFilter by API ID
--envFilter by environment
--statusFilter by status: pending, in_progress, success, failed, rolled_back
--pagePage number (default: 1)
--page-sizeItems per page (default: 20)
-oOutput format: table, wide, yaml, json

Example:

stoactl deploy list --env production --status success -o wide

stoactl deploy get

Get detailed information about a specific deployment.

stoactl deploy get <deployment-id>

Example:

stoactl deploy get deploy-abc12345
stoactl deploy get deploy-abc12345 -o json

stoactl deploy rollback

Rollback a deployment to its previous version.

stoactl deploy rollback <deployment-id>

Example:

# Find the deployment to roll back
stoactl deploy list --api-id customer-api --env production

# Roll back
stoactl deploy rollback deploy-abc12345

stoactl logs

Show deployment history for an API — recent deployments, statuses, and error messages.

stoactl logs <api-name> [flags]

Flags:

FlagDefaultDescription
--envFilter by environment (dev, staging, production)
--limit10Number of recent deployments to show

Example:

stoactl logs customer-api
stoactl logs customer-api --env production --limit 5

Output columns: ID, ENV, VERSION, STATUS, BY, STARTED, MESSAGE

Status values:

StatusMeaning
OKDeployment succeeded
FAILDeployment failed (see MESSAGE column)
...Deployment in progress
WAITDeployment queued
<<<Deployment was rolled back

Project Commands

stoactl init

Create a new STOA project with everything needed to run a local MCP gateway.

stoactl init <name> [flags]

Flags:

FlagDefaultDescription
--port8080Gateway port
--dir.Parent directory for the project
--no-contextfalseSkip creating a local CLI context

Example:

stoactl init my-api --port 9090
cd my-api
docker compose up -d
stoactl doctor

Generated files:

  • docker-compose.yml — Gateway + echo backend
  • stoa.yaml — Gateway configuration
  • echo-nginx.conf — Echo backend (static JSON for testing)
  • example-api.yaml — Sample OpenAPI spec for bridge
  • README.md — Project-specific quickstart
  • tools/ — Output directory for bridge

stoactl doctor

Run 6 diagnostic checks to verify your local setup.

stoactl doctor

Checks:

CheckWhat it verifies
DockerDocker daemon is running
GatewayHealth endpoint responds (HTTP 200)
KeychainOS Keychain is accessible
API keyValid authentication token exists
PortGateway port is available
MCP endpointSSE endpoint is responding

Bridge Commands

stoactl bridge

Convert an OpenAPI 3.x specification into STOA Tool CRDs. Each path+method operation becomes a separate MCP tool.

stoactl bridge <spec-file> [flags]

Flags:

FlagDefaultDescription
--namespace(required)Target namespace for generated tools
--output./tools/Output directory for YAML files
--serverFrom specOverride servers[0].url
--auth-secretK8s secret name for authentication
--include-tagsAllOnly include operations with these tags
--exclude-tagsNoneExclude operations with these tags
--include-opsAllOnly include these operationIds
--timeout30sDefault timeout for generated tools
--dry-runfalseShow summary without writing files
--applyfalseRegister tools directly via API (planned)

Examples:

# Generate tools from an OpenAPI spec
stoactl bridge petstore.yaml --namespace tenant-acme

# Preview without writing files
stoactl bridge petstore.yaml --namespace tenant-acme --dry-run

# Filter by tags
stoactl bridge api.yaml --namespace default --include-tags payments --exclude-tags internal

# Override backend URL
stoactl bridge api.yaml --namespace default --server https://api.internal.com

Mapping rules:

OpenAPI FieldTool CRD Field
operationIdmetadata.name (kebab-case)
summaryspec.displayName
descriptionspec.description
servers[0].url + pathspec.endpoint
HTTP methodspec.method
parameters + requestBodyspec.inputSchema
security + securitySchemesspec.authentication
tagsspec.tags

Resource Commands

stoactl apply

Create or update a resource from a YAML file.

stoactl apply -f <file>

Example:

# Apply a single tool
stoactl apply -f tools/list-pets.yaml

# Apply all tools in a directory
for f in tools/*.yaml; do stoactl apply -f "$f"; done

stoactl get

List resources from the control plane.

stoactl get <resource-type>

Resource types: apis, deployments, tools

Example:

stoactl get apis
stoactl get tools
stoactl get deployments

stoactl delete

Delete a resource.

stoactl delete <resource-type> <name>

Example:

stoactl delete tool list-pets
stoactl delete api payment-api

Authentication Commands

stoactl auth login

Authenticate with STOA Platform using OAuth2 device flow.

stoactl auth login

This initiates the device authorization flow:

  1. You receive a code and URL
  2. Open the URL in your browser
  3. Enter the code to authorize
  4. Credentials are stored in your OS Keychain

stoactl auth logout

Remove stored credentials.

stoactl auth logout

stoactl auth whoami

Display current authentication status.

stoactl auth whoami

stoactl auth rotate-key

Generate a new API key and store it in the OS Keychain.

stoactl auth rotate-key [flags]
FlagDefaultDescription
--autofalseEnable automatic rotation reminder
--interval90dRotation interval

Configuration Commands

stoactl config set-context

Create or update a named context.

stoactl config set-context <name> --server <url> --tenant <tenant>

Example:

stoactl config set-context prod --server ${STOA_API_URL} --tenant acme
stoactl config set-context local --server http://localhost:8080 --tenant default

stoactl config use-context

Switch to a named context.

stoactl config use-context <name>

stoactl config get-contexts

List all configured contexts.

stoactl config get-contexts

Utility Commands

stoactl token-usage

View API token usage statistics.

stoactl token-usage

stoactl version

Print version and build information.

stoactl version

Workflows

Deploy an API (stoa.yaml)

# 1. Authenticate
stoactl auth login

# 2. Create stoa.yaml (or export from Console)
cat > stoa.yaml <<EOF
name: customer-api
version: 2.0.0
rate_limit:
requests_per_minute: 1000
auth:
type: oauth2
issuer: ${STOA_AUTH_URL}/realms/acme
required: true
EOF

# 3. Deploy to staging first
stoactl deploy ./stoa.yaml --env staging --watch

# 4. Check logs
stoactl logs customer-api --env staging

# 5. Deploy to production
stoactl deploy ./stoa.yaml --env production --watch

Rollback a failed deployment

# 1. Find the failed deployment
stoactl deploy list --api-id customer-api --env production

# 2. Roll back
stoactl deploy rollback deploy-abc12345

# 3. Confirm rollback succeeded
stoactl logs customer-api --env production --limit 3

Bridge an API to MCP

# 1. Set up project
stoactl init my-api && cd my-api

# 2. Start gateway
docker compose up -d

# 3. Verify setup
stoactl doctor

# 4. Connect to hosted platform (optional)
stoactl config set-context prod --server ${STOA_API_URL} --tenant acme
stoactl auth login

# 5. Bridge your API to MCP
stoactl bridge your-api.yaml --namespace default --output ./tools/

# 6. Register tools
for f in tools/*.yaml; do stoactl apply -f "$f"; done

# 7. Verify
stoactl get tools