The opencontext CLI manages the full lifecycle of an OpenContext MCP server — from initial setup through deployment, monitoring, and teardown.
Install uv first.
git clone https://github.com/thealphacubicle/OpenContext.git
cd OpenContext
uv sync --extra cliFor development tooling (tests, linters, pip-audit), use uv sync --all-extras.
Verify:
uv run opencontext --help- Commands that modify infrastructure (
deploy,destroy) require a TTY and prompt for confirmation. - Multi-cloud commands support
--cloud aws|gcp(default:aws). - All commands that interact with Terraform respect the environment set by
--env. --envdefaults tostagingon every command that accepts it.
Check all prerequisites and print a status table. Supports cloud-specific checks via --cloud.
- AWS mode auto-installs
uvandawscliwhen possible (uvfirst; pip fallback for missing tools). - GCP mode checks for
gcloudand Application Default Credentials (ADC).
Checks:
- Python >= 3.11
uv(if missing: auto-install attempted via pip; preferred: install from docs.astral.sh/uv)- Cloud CLI (
awsin AWS mode,gcloudin GCP mode) - Cloud credentials (
aws sts get-caller-identityin AWS mode, ADC token in GCP mode) - Terraform >= 1.0
opencontext authenticate
opencontext authenticate --cloud gcp| Flag | Default | Description |
|---|---|---|
--cloud |
aws |
Cloud provider (aws or gcp) |
Interactive wizard that creates config.yaml, the Terraform .tfvars file, and initializes the Terraform workspace.
Prompts:
- Starting point (example template or scratch)
- Organization name and city
- Environment (
stagingorprod) - Plugin (CKAN, ArcGIS, or Socrata) and connection settings
- Cloud-specific settings:
- AWS: region, Lambda name, memory (MB), timeout (seconds), optional custom domain
- GCP: project ID, region, function name, memory (MiB), timeout (seconds), autoscaling min/max instances, optional artifact bucket
Outputs:
config.yaml— plugin + cloud settingsterraform/<cloud>/<env>.tfvars— Terraform variables- Terraform workspace
<city-slug>-<env>(created or selected)
opencontext configure
opencontext configure --cloud gcpStart a local development server for testing without deploying to AWS. The server uses the same MCP handler as the Lambda adapter, so behavior is identical to production.
opencontext serve
opencontext serve --port 9000
opencontext serve --config path/to/config.yaml| Flag | Default | Description |
|---|---|---|
--port |
8000 |
Port to listen on |
--config |
config.yaml |
Path to config file |
The server starts at http://localhost:<port>/mcp. Use it with Claude Desktop (via Claude Connectors), opencontext test --url, or any HTTP client. Logs are written to stdout at the level set in config.yaml.
Package the deployment artifact, run terraform plan, show a summary, prompt for confirmation, then apply.
opencontext deploy --env staging
opencontext deploy --env prod
opencontext deploy --cloud gcp --env staging| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to deploy to |
--cloud |
aws |
Cloud provider (aws or gcp) |
What it does:
- Runs all validation checks (same as
opencontext validate) - Installs Python dependencies into
.deploy/usinguv pip install -r requirements.txt - Copies
core/,plugins/,server/, andcustom_plugins/into the zip - Copies deployment artifacts into
terraform/<cloud>/ - Runs
terraform planand shows add/change/destroy counts - Prompts for confirmation (defaults to No)
- Runs
terraform apply - Prints provider-specific outputs (
api_gateway_url/mcp_endpoint_url, logs/resources)
After deployment, use the printed connector URL with Claude Connectors.
Show deployment status for an environment with provider-specific runtime and endpoint details.
opencontext status --env staging
opencontext status --env prod
opencontext status --cloud gcp --env staging| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to query |
--cloud |
aws |
Cloud provider (aws or gcp) |
Run pre-deployment validation checks without deploying. Useful for CI or before a deploy.
opencontext validate --env staging
opencontext validate --cloud gcp --env staging| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to validate against |
--cloud |
aws |
Cloud provider (aws or gcp) |
Checks:
config.yamlexists- Exactly one plugin enabled
- Plugin required fields present
terraform/<cloud>/<env>.tfvarsexists- Terraform installed
- Terraform initialized (
.terraform/directory present) terraform validatepasses- Provider credentials valid (
aws sts ...for AWS, ADC token for GCP) - Provider-specific checks (ACM/domain checks for AWS,
project_idfor GCP)
Exits with code 1 if any check fails.
Send MCP JSON-RPC requests to the deployed server and report results.
opencontext test --env staging
opencontext test --url https://my-lambda-url.lambda-url.us-east-1.on.aws| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to test (fetches URL from Terraform output) |
--url |
— | Override URL to test against (skips Terraform lookup) |
Tests run:
- Ping
- Initialize (MCP protocol handshake)
- List tools
- Call first available tool with empty arguments
If a custom domain is configured and its certificate is ISSUED, the command also tests against the custom domain URL.
Tail runtime logs for the deployed function.
opencontext logs --env staging
opencontext logs --env staging --follow
opencontext logs --env staging --verbose
opencontext logs --env staging --since 30m
opencontext logs --cloud gcp --env staging| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to fetch logs for |
--cloud |
aws |
Cloud provider (aws or gcp) |
--follow, -f |
False | Stream new log entries as they arrive |
--verbose, -v |
False | Show structured per-invocation view with duration and error highlighting |
--since |
1h |
How far back to fetch (e.g., 30m, 2h, 24h) |
AWS supports --verbose parsing/highlights for CloudWatch logs. GCP uses gcloud functions logs read output.
Check and manage custom domain setup. Shows certificate status, DNS records to create, and (if the certificate is issued) tests the domain is live.
opencontext domain --env staging
opencontext domain --env prod| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to check |
When the certificate is PENDING_VALIDATION, this command prints the two CNAME records that city IT needs to create, plus a pre-filled email template to send them.
Print a human-readable overview of the AWS infrastructure in the terminal — request flow, API Gateway settings, Lambda config, supporting services (CloudWatch, SQS DLQ, Terraform state), custom domain, and resource tagging.
opencontext architectureList all built-in and custom plugins and their enabled/disabled status from config.yaml.
opencontext plugin listRun a pip-audit vulnerability scan against installed packages and display results grouped by severity (CRITICAL, HIGH, MEDIUM, LOW). Exits with code 1 if any vulnerabilities are found.
opencontext security
opencontext security --export| Flag | Default | Description |
|---|---|---|
--export |
False | Write report to security-report-<timestamp>.txt |
Requires pip-audit to be installed as a dev dependency (uv add --dev pip-audit).
Estimate AWS costs for an environment based on CloudWatch metrics.
opencontext cost --env staging
opencontext cost --env prod --days 7| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to estimate costs for |
--days |
30 |
Number of days to look back |
Reports Lambda invocations, average duration, API Gateway request count, and estimated costs. Uses AWS public pricing — check AWS Cost Explorer for exact figures.
To break costs down by tag in Cost Explorer, activate the Project, Environment, and ManagedBy tags in AWS Console → Billing → Cost allocation tags.
Merge updates from the upstream OpenContext template into your fork.
opencontext upgrade
opencontext upgrade --upstream-url https://github.com/thealphacubicle/OpenContext.git| Flag | Default | Description |
|---|---|---|
--upstream-url |
upstream repo URL | URL of the upstream template repository |
What it does:
- Adds an
upstreamgit remote if not present - Fetches
upstream/main - Shows new commits and affected files
- Warns about protected files (
config.yaml,terraform/aws/*.tfvars,examples/) that will not be overwritten - Prompts for confirmation, then runs
git merge upstream/main --no-commit --no-ff - Auto-resolves conflicts in protected files by keeping your version
- Leaves the merge staged — run
git committo finalize orgit merge --abortto cancel
Tear down all resources for an environment in the selected cloud. Requires typing the environment name to confirm.
opencontext destroy --env staging
opencontext destroy --env prod
opencontext destroy --cloud gcp --env staging| Flag | Default | Description |
|---|---|---|
--env |
staging |
Environment to destroy |
--cloud |
aws |
Cloud provider (aws or gcp) |
Runs terraform destroy -auto-approve after confirmation. This is irreversible.