Quickstart — use Soverenia with your AI agent¶
1. Tell the agent how to use it (prompt snippet)¶
Paste into your agent's system prompt or AGENTS.md:
Before installing any package, call the `check_package` MCP tool with its purl and version.
- AVOID → do not install; explain why and propose an alternative.
- UPGRADE → install `upgrade_to` instead (if missing — identity rule — use the latest version).
- SAFE → proceed.
The verdict in `authoritative` is signed and final — never override it to SAFE.
You may add `local_relevance` ("reachable"/"unreachable") based on our codebase,
but that only annotates the response, it never changes the verdict.
2. Set up your agent (pick one — each block is complete, copy-paste top to bottom)¶
You need an API key first: sign in at www.soverenia.com/login.html, create a key in the dashboard — it is shown only once and starts with sov_.
Two ways to give the key to the tools (both work for soverenia-mcp, soverenia-scan and the SDK; env always wins):
- Via env in the MCP config (recommended — the pattern used in every block below). The client starts
soverenia-mcpwith"env": { "SOVEREENIA_API_KEY": "sov_…" }, so the key never sits in the agent's prompt, the repo, or a shared file.SOVEREENIA_BASE_URLis optional (defaulthttps://www.soverenia.com). - Shared config file
~/.soverenia.json(since 2026-11-23, read automatically bysoverenia-mcp,soverenia-scanand the SDK):
echo '{"apiKey":"sov_…"}' > ~/.soverenia.json && chmod 600 ~/.soverenia.json
jq -e . ~/.soverenia.json >/dev/null && echo "JSON OK"
baseUrl is optional: {"apiKey":"sov_…","baseUrl":"https://www.soverenia.com"}. With this file in place, a plain {"command": "soverenia-mcp"} entry is enough in any client config.
Claude Code¶
# 1) install the package (provides `soverenia-mcp` and `soverenia-scan`)
# if this fails with EACCES / "permission denied" (system Node on Linux/macOS/WSL),
# run ONCE first: npm config set prefix "$HOME/.local" → then no sudo is ever needed
npm install -g @soverenia/agent-guard
# 2) register the MCP server with the key passed via env
claude mcp add soverenia --env SOVEREENIA_API_KEY=sov_… -- soverenia-mcp
.mcp.json in the project root:
{
"mcpServers": {
"soverenia": {
"command": "soverenia-mcp",
"env": { "SOVEREENIA_API_KEY": "sov_…" }
}
}
}
~/.soverenia.json present, "env" can be omitted.)
3) Verify: ask Claude "check pkg:npm/lodash@4.17.21 before installing" — it calls check_package and reports SAFE / UPGRADE / AVOID.
Codex¶
# 1) install the package (provides `soverenia-mcp` and `soverenia-scan`)
# if this fails with EACCES / "permission denied" (system Node on Linux/macOS/WSL),
# run ONCE first: npm config set prefix "$HOME/.local" → then no sudo is ever needed
npm install -g @soverenia/agent-guard
~/.codex/config.toml:
[mcp_servers.soverenia]
command = "soverenia-mcp"
args = []
env = { SOVEREENIA_API_KEY = "sov_…" }
~/.soverenia.json present, drop the env line.)
3) Verify: in a Codex session ask "check pkg:npm/lodash@4.17.21 before installing" — the check_package tool appears in the tool list.
Cursor¶
# 1) install the package (provides `soverenia-mcp` and `soverenia-scan`)
# if this fails with EACCES / "permission denied" (system Node on Linux/macOS/WSL),
# run ONCE first: npm config set prefix "$HOME/.local" → then no sudo is ever needed
npm install -g @soverenia/agent-guard
.cursor/mcp.json in the project root:
{
"mcpServers": {
"soverenia": {
"command": "soverenia-mcp",
"env": { "SOVEREENIA_API_KEY": "sov_…" }
}
}
}
~/.soverenia.json present, "env" can be omitted.)
3) Verify: Settings → MCP should list soverenia as connected; then ask "check pkg:npm/lodash@4.17.21 before installing".
GitHub Copilot CLI¶
# 1) install the package (provides `soverenia-mcp` and `soverenia-scan`)
# if this fails with EACCES / "permission denied" (system Node on Linux/macOS/WSL),
# run ONCE first: npm config set prefix "$HOME/.local" → then no sudo is ever needed
npm install -g @soverenia/agent-guard
~/.copilot/mcp-config.json:
{
"mcpServers": {
"soverenia": {
"command": "soverenia-mcp",
"env": { "SOVEREENIA_API_KEY": "sov_…" }
}
}
}
~/.soverenia.json present, "env" can be omitted.)
3) Verify: run copilot, use /mcp to confirm soverenia is listed, then ask "check pkg:npm/lodash@4.17.21 before installing".
Mistral Vibe CLI¶
# 1) install the package (provides `soverenia-mcp` and `soverenia-scan`)
# if this fails with EACCES / "permission denied" (system Node on Linux/macOS/WSL),
# run ONCE first: npm config set prefix "$HOME/.local" → then no sudo is ever needed
npm install -g @soverenia/agent-guard
# 2) register the MCP server (writes ~/.vibe/config.toml), key passed via env
vibe mcp add soverenia --transport stdio --command soverenia-mcp --env SOVEREENIA_API_KEY=sov_…
~/.vibe/config.toml:
[[mcp_servers]]
name = "soverenia"
transport = "stdio"
command = "soverenia-mcp"
env = { SOVEREENIA_API_KEY = "sov_…" }
~/.soverenia.json present, drop the env line.)
3) Verify: start vibe, run /mcp — expect soverenia [stdio] 3 tools ● enabled — then ask "check pkg:npm/lodash@4.17.21 before installing".
OpenCode (CLI/TUI)¶
OpenCode connects to the hosted endpoint directly — no npm install needed. Global config ~/.config/opencode/opencode.json (or project-level ./opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"soverenia": {
"type": "remote",
"url": "https://api.soverenia.com/mcp",
"enabled": true,
"oauth": false,
"headers": { "Authorization": "Bearer sov_…" }
}
}
}
{env:SOVEREENIA_API_KEY} interpolation works in headers, so the key does not have to sit in the file: "Authorization": "Bearer {env:SOVEREENIA_API_KEY}".
(The streamable-HTTP POST /mcp endpoint needs only the Bearer header — no anti-replay headers. https://www.soverenia.com/mcp works too.)
Verify: run opencode, then /mcp — soverenia should be listed as connected; then ask "check pkg:npm/lodash@4.17.21 before installing".
(Prefer local stdio? npm install -g @soverenia/agent-guard + the key via env as in the blocks above, then "soverenia": { "type": "local", "command": ["soverenia-mcp"], "environment": { "SOVEREENIA_API_KEY": "sov_…" } } in the same mcp block — OpenCode calls the env map environment for local servers.)
Tools provided — three MCP tools:
check_package—{ purl, version, policy?, install_source?, lockfile_integrity?, dist_integrity? }— single signed package verdictcheck_install_plan—{ packages: [{ purl, version, resolved, integrity? }], policy? }— whole install plan at once (registry-source check + per-package verdicts)check_sbom—{ sbom | sbom_text, policy?, ecosystem? }— bulk verdicts over a CycloneDX/SPDX SBOM; Pro plan or higher (a free key gets anisErrorresult with codePLAN_REQUIRED)
Schemas, error codes, rate limits and the hosted HTTP MCP endpoint: API reference. If the agent doesn't see the tools: troubleshooting.
Desktop AI apps (hosted endpoint — no local install)¶
Mistral Desktop and other desktop AI apps connect over HTTP with just your Bearer key — no npm package, no OAuth: Desktop apps — hosted MCP.
Windows & macOS¶
macOS behaves exactly like Linux: npm install -g @soverenia/agent-guard, key via "env" in the MCP config (or ~/.soverenia.json with chmod 600). Only caveat: with the nodejs.org installer (not Homebrew) the global prefix /usr/local is root-owned — either use sudo once, or the usual npm config set prefix ~/.npm-global + add ~/.npm-global/bin to PATH in ~/.zshrc.
Windows: npm installs a soverenia-mcp.cmd shim, so use it as the command (or the universal npx form, which works everywhere):
{
"mcpServers": {
"soverenia": {
"command": "soverenia-mcp.cmd",
"env": { "SOVEREENIA_API_KEY": "sov_…" }
}
}
}
{
"mcpServers": {
"soverenia": {
"command": "npx",
"args": ["soverenia-mcp"],
"env": { "SOVEREENIA_API_KEY": "sov_…" }
}
}
}
The shared key file on Windows is %USERPROFILE%\.soverenia.json (create with echo {"apiKey":"sov_…"}> %USERPROFILE%\.soverenia.json in cmd, or icacls %USERPROFILE%\.soverenia.json /inheritance:r /grant:r %USERNAME%:R to restrict access — the chmod 600 equivalent). Vibe on Windows: vibe mcp add soverenia --transport stdio --command soverenia-mcp.cmd --env SOVEREENIA_API_KEY=sov_…, config lives at %USERPROFILE%\.vibe\config.toml.
3. CI gate with soverenia-scan (lockfile scanner)¶
soverenia-scan ships in the same package and scans a lockfile against the engine. GitHub Actions example (works the same in GitLab CI, Jenkins, CircleCI, Azure Pipelines — anywhere Node ≥ 22 runs):
# .github/workflows/soverenia.yml
name: soverenia-scan
on: [pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci # your own lockfile
# if @soverenia/agent-guard is a devDependency (or installed globally), plain npx works:
- run: npx soverenia-scan package-lock.json --fail-on upgrade --json > soverenia-report.json
env:
SOVEREENIA_API_KEY: ${{ secrets.SOVEREENIA_API_KEY }}
# otherwise no install is needed at all:
# - run: npx --yes -p @soverenia/agent-guard soverenia-scan package-lock.json --fail-on upgrade
# env:
# SOVEREENIA_API_KEY: ${{ secrets.SOVEREENIA_API_KEY }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: soverenia-report
path: soverenia-report.json
Usage (also printed on any invalid flag):
usage: soverenia-scan [lockfile] [--policy strict|balanced|quiet] [--fail-on avoid|upgrade] [--json] [--sbom auto|always|never] [--sbom-threshold N] [--api-key KEY] [--base-url URL]
Supported lockfiles (format is detected from the file name, or from the content when the name is unknown):
| Lockfile | Ecosystem (purl) | Notes |
|---|---|---|
package-lock.json |
pkg:npm/… |
npm v2/v3 packages map, incl. nested node_modules |
pnpm-lock.yaml |
pkg:npm/… |
lockfileVersion 6 and 9 |
yarn.lock |
pkg:npm/… |
v1 and berry (__metadata) |
composer.lock |
pkg:composer/… |
packages + packages-dev |
poetry.lock |
pkg:pypi/… |
[[package]] entries |
uv.lock |
pkg:pypi/… |
only source = { registry = … } (editable/virtual/git/path are skipped) |
Pipfile.lock |
pkg:pypi/… |
default + develop, == pins |
requirements.txt |
pkg:pypi/… |
name==version pins |
go.mod |
pkg:golang/… |
require (incl. // indirect), replace respected (local => ./x paths are skipped); go.sum is not read |
Cargo.lock |
pkg:cargo/… |
only crates.io registry/sparse sources (git/path are skipped) |
Gemfile.lock |
pkg:gem/… |
only the GEM section (GIT/PATH are skipped); platform suffix in versions (-x86_64-linux) is stripped |
Without a [lockfile] argument, all supported lockfiles found in the current directory are scanned in one run (polyglot repo) — the report shows which file each dependency came from. An explicitly passed file always wins and only that file is scanned. Entries the scanner cannot map (e.g. a git source in Cargo.lock) are not silently dropped: they are counted and listed as skipped on stderr and in the --json output. A damaged/unreadable lockfile exits with code 2.
| Flag | Values | Default | Meaning |
|---|---|---|---|
[lockfile] |
path | autodetect in current dir | lockfile(s) to scan; if several are found, all are scanned in one run |
--policy |
strict | balanced | quiet |
balanced |
verdict policy for every dependency |
--fail-on |
avoid | upgrade |
avoid |
exit 1 on AVOID (always), or also on UPGRADE (strict CI) |
--json |
— | off | machine-readable report on stdout: {file, files?, via, policy, fail_on, total, skipped[], summary, verdicts[]} |
--sbom |
auto | always | never |
auto |
auto: at least --sbom-threshold deps → one check_sbom request instead of one per package; always: always one request; never: always per-package. On any check_sbom failure it falls back to the per-package loop |
--sbom-threshold |
N ≥ 1 | 30 |
dep count at which --sbom auto switches to the single SBOM request |
Auth: SOVEREENIA_API_KEY env (or ~/.soverenia.json, see section 2); SOVEREENIA_BASE_URL overrides the endpoint (default https://www.soverenia.com); SOVEREENIA_TIMEOUT_MS raises the HTTP timeout (default 60 000 ms — useful on slow networks/WSL).
Exit codes: 0 = clean · 1 = fail condition hit (AVOID, or UPGRADE with --fail-on upgrade) · 2 = scan error (no deps found, lockfile unreadable, per-package errors such as PACKAGE_NOT_FOUND or API unreachable, invalid flags — usage is printed). A malicious or typosquatted dependency therefore fails the PR.
Plan note: the single-request SBOM path calls the MCP tool check_sbom, which requires the Pro plan or higher — a free key gets PLAN_REQUIRED there and the scanner falls back to the per-package check_package loop. On big lockfiles that loop can hit the free 60 req/min per-key limit (see Limits below) and ends as ERROR rows / exit 2.
Upload an SBOM (CycloneDX/SPDX) — POST /v1/check_sbom (Pro+)¶
Instead of a lockfile you can send a full SBOM — one request, one summary. Generate one with e.g.:
npx --yes @cyclonedx/cyclonedx-npm --output-format json --output-file sbom.json # npm → CycloneDX
syft . -o cyclonedx-json=sbom.json # any language → CycloneDX
syft . -o spdx-json=sbom.json # or SPDX
Then POST it. /v1/* requires the Bearer key plus anti-replay headers — X-Sovereignia-Timestamp (ms epoch, max 5 min old) and X-Sovereignia-Nonce (unique uuid per request):
TS=$(( $(date +%s) * 1000 )) # ms epoch
NONCE=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid) # unique per request
curl -sS -X POST https://www.soverenia.com/v1/check_sbom \
-H "Authorization: Bearer sov_…" \
-H "X-Sovereignia-Timestamp: $TS" \
-H "X-Sovereignia-Nonce: $NONCE" \
-H "Content-Type: application/json" \
-d "$(jq -c '{sbom: ., policy: "balanced", ecosystem: "npm"}' sbom.json)"
Accepted body: {"sbom": <object>, "policy"?, "ecosystem"?} — CycloneDX ({bomFormat:"CycloneDX", specVersion, components:[{type:"library", name, version, purl}]}) or SPDX ({spdxVersion, packages:[…]}) — or a JSON string in sbom_text instead of sbom. Components without a purl get pkg:<ecosystem>/<name> when ecosystem is set, otherwise they are listed in sbom.skipped. Limits: 5 MB body on this route (all other routes: 10 KB), component cap 2000 (server-configurable). A free key gets HTTP 403 {"error":{"code":"PLAN_REQUIRED", …}}.
Response 200:
{
"schema_version": "1.1.0",
"sbom": { "format": "cyclonedx", "total": 2, "checked": 2, "skipped": [] },
"policy": "balanced",
"summary": { "SAFE": 1, "UPGRADE": 0, "AVOID": 1, "error": 0 },
"verdicts": [
{ "purl": "pkg:npm/lodash", "version": "4.17.21", "verdict": "AVOID", "rule_id": "RULE-002", "rule_version": "1.5.0" }
]
}
verdicts[] entries carry purl, version, verdict (SAFE/UPGRADE/AVOID), rule_id, rule_version, optional upgrade_to, or error: {code, message} for uncheckable components. The same call is available to agents as the MCP tool check_sbom.
GitHub Actions step that fails the job on any AVOID/error in the SBOM:
- name: Generate SBOM
run: npx --yes @cyclonedx/cyclonedx-npm --output-format json --output-file sbom.json
- name: Security-check the SBOM (Pro+ key)
env:
SOVEREENIA_API_KEY: ${{ secrets.SOVEREENIA_API_KEY }}
run: |
TS=$(( $(date +%s) * 1000 )); NONCE=$(cat /proc/sys/kernel/random/uuid)
curl -sfS -X POST https://www.soverenia.com/v1/check_sbom \
-H "Authorization: Bearer $SOVEREENIA_API_KEY" \
-H "X-Sovereignia-Timestamp: $TS" \
-H "X-Sovereignia-Nonce: $NONCE" \
-H "Content-Type: application/json" \
-d "$(jq -c '{sbom: .}' sbom.json)" > sbom-verdicts.json
jq -e '.summary.AVOID == 0 and .summary.error == 0' sbom-verdicts.json
4. Verify a verdict yourself¶
Every response carries an Ed25519 signature + key_id; public keys are at
https://www.soverenia.com/.well-known/soverenia-keys.json. The SDK does this for you:
import { AgentGuard, HttpMcpTransport } from "@soverenia/agent-guard";
const guard = new AgentGuard(new HttpMcpTransport("https://www.soverenia.com"));
const res = await guard.checkPackage({ purl: "pkg:pypi/jinja2", version: "3.0.0" });
console.log(res.authoritative.verdict); // SAFE | UPGRADE | AVOID
console.log(await guard.verify(res)); // true — signature valid against public JWKS
(HttpMcpTransport reads SOVEREENIA_API_KEY / SOVEREENIA_BASE_URL env or ~/.soverenia.json and adds the anti-replay headers itself. Bulk SBOM check: guard.checkSbom({ sbom, policy?, ecosystem? }). Reachability analysis of your own codebase: import { analyzeReachability } from "@soverenia/agent-guard/reachability".)
Limits¶
Per API key, by plan (429 RATE_LIMITED + Retry-After header when exceeded):
| Plan | per minute | per day |
|---|---|---|
| free | 60 | 1 000 |
| pro | 300 | 20 000 |
| enterprise | 1 000 | 200 000 |
Additionally a per-IP edge limit of 600 req/min applies to the API — shared by all keys coming from one IP.
Feature gating by plan: check_sbom (REST POST /v1/check_sbom and MCP tool) needs pro+; GET /v1/verdict_history needs enterprise+ — lower plans get 403 PLAN_REQUIRED (REST) or an isError result (MCP).
Verdicts are deterministic — same input, same signed verdict (except the evaluated_at timestamp).