Skip to main content
Glama
sovereign

sovereign

by kraken222

Sovereign MCP

Your AI assistant writes Terraform. This checks it before you do.

An MCP server that scans Terraform for security misconfigurations while the code is being generated, not after it lands in a pull request. It runs locally, needs no account, and your infrastructure code never leaves your machine.

Detection is Checkov (Apache-2.0), vendored so it runs offline and pinned to the same version the backend evaluates. What this adds is the shape around it: findings compact enough to sit in an assistant's context, curated remediation per check, a narrow allowlist of fixes that are safe to apply mechanically, hardened templates and org policy served before generation, and a handful of checks Checkov does not cover — a credential written as a literal in the HCL among them.

You:       "add an RDS instance for the orders service"
Assistant: [writes HCL] → [scans it] → [fixes 4 findings] → shows you the result

Why this exists

Provider defaults optimise for it works, not it is safe. Terraform generated from a model's memory is routinely unencrypted, publicly reachable, or missing deletion protection — and the cost of fixing that rises steeply the further it travels. In the editor it is one attribute. In a PR it is a review cycle. In production it is an incident.

CI already catches this. CI catches it three days and one argument later.


Related MCP server: Cybrium MCP Server

Install

Claude Code

claude mcp add sovereign -- uvx sovereign-observer

Cursor

~/.cursor/mcp.json:

{
  "mcpServers": {
    "sovereign": {
      "command": "uvx",
      "args": ["sovereign-observer"]
    }
  }
}

VS Code (GitHub Copilot)

.vscode/mcp.json:

{
  "servers": {
    "sovereign": {
      "type": "stdio",
      "command": "uvx",
      "args": ["sovereign-observer"]
    }
  }
}

Windsurf

~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "sovereign": {
      "command": "uvx",
      "args": ["sovereign-observer"]
    }
  }
}

First run downloads the engine (~100 MB) and takes a moment. After that it is local and fast.


Environments

A scanner that reports the same severity everywhere gets muted. Multi-AZ and deletion protection are the right call in production and noise on a sandbox torn down nightly, and once someone has dismissed the same Critical five times on a scratch stack they stop reading the output at all.

So every finding is tagged with the environment it was inferred to belong to, from an Environment tag or the directory the file sits in. unknown is a normal answer and changes nothing.

Passing environment_aware to scan_terraform lets that inference move severity — but only for an explicit allowlist of resilience, monitoring and housekeeping checks. Public access, encryption, identity and hardcoded credentials never move, in any environment. A dev bucket is usually where last month's production dump lives.

It is off by default, because a scan that quietly drops a finding below the level your merge gate keys on has weakened your pipeline without asking. Nothing is ever lowered below Low, and a finding that moved says what it moved from.


Tools

Tool

What it does

scan_terraform

Scan HCL — from disk or an unsaved buffer. Returns findings by severity with file and line, each tagged with its inferred environment.

explain_finding

The full remediation for one finding: what is wrong and the exact Terraform to fix it.

apply_fixes

Apply the mechanically-safe fixes and return patched HCL.

secure_template

A hardened starting point for a resource type, so the insecure version never gets written.

check_compliance

Map findings to SOC 2, ISO 27001, NIST 800-53, PCI-DSS, DORA, NIS2, NCA (Saudi), NESA (UAE).

framework_coverage

Which articles of a regulation automated scanning can and cannot evidence.

org_requirements

Your organization's own rules for a resource type — before the code is written.

org_status

Whether org policy is in force, or built-in rules only.

You do not call these. The assistant does, on its own, because the server tells it to.


Organization policy

Everything above works with no account. Connecting an organization adds your company's own rules to the same local evaluation:

export SOVEREIGN_TOKEN=...   # Integrations → GitHub in the dashboard

The difference this makes is in when the rule applies. Without it, the assistant writes Terraform and then finds out it was wrong. With it:

You:       "add an RDS instance for the orders service"
Assistant: → org_requirements("aws_db_instance")
           ← "backup_retention_period must be at least 365"
             "region must be one of: eu-west-1, eu-central-1"
           [writes Terraform that already satisfies both]
           → scan_terraform → clean

The rule is supplied to the generator, not applied to the output. That is the whole point — a violation that never gets written costs nothing to fix.

Company rules appear in scans tagged source: org_policy, so a developer can always tell a company requirement from a built-in one. They are authored in the dashboard as YAML and enforced identically in the editor, in CI, and in a cloud scan.

This does not change what leaves your machine. Rules come down; code never goes up. The only request this server makes is a GET for your org's rules — tests/test_org_policy.py::test_no_terraform_is_ever_uploaded asserts that at the transport, and asserts an unconnected install opens no socket at all. If the API is unreachable or the token is rejected, the built-in rules still run locally and the scan still works.


What it does not do

Worth stating plainly, because a security tool that overstates its scope is worse than no tool:

  • It is not a compliance assessment. check_compliance returns control mappings — evidence that shortens an audit. Every framework it maps also carries governance, process and training obligations no configuration scanner can observe. A clean scan is not a compliant organisation.

  • NCA control identifiers are provisional, pending reconciliation against the authority's published catalogue. Cite the subdomain names.

  • apply_fixes is deliberately narrow. It applies only single-attribute, in-place changes from a hand-verified allowlist, and never overwrites a value wired to a variable or expression. Everything else stays advisory, because a mechanical fix that is syntactically clean can still take a running system down.

  • It scans Terraform, not live cloud accounts, container images, or dependencies.

For live multi-cloud posture management, attack-path analysis and audit-ready reporting, this is the editor-side slice of Sovereign Observer.


Privacy

The scan runs in this process, on your machine. There is no API key, no account, and no network call in the default path — the server works with networking disabled. Your Terraform is never uploaded.


Development

pip install -e ".[dev]"
python -m pytest tests/ -q

sovereign_mcp/_vendor/ holds the IaC engine. In the Sovereign Observer monorepo those modules are generated at build time by scripts/vendor_engine.py so the rule logic has exactly one source; here they are committed so this package builds on its own. Edit them upstream, not here — changes made in this repository are overwritten on the next sync.

tests/test_parity.py verifies the vendored copies match their upstream source and that the Checkov pin matches the backend's. Those checks skip automatically outside the monorepo, since there is nothing to compare against.

Licensed Apache-2.0. Built on Checkov (Apache-2.0).

Available Tools

8 tools
apply_fixesApply the safe fixes to Terraform sourceA

Apply the mechanically-safe fixes from scan_terraform to Terraform source and return the patched HCL. Pass the file content plus the findings you want fixed (each as {check_id, resource_address}). Only fixes on the hand-verified allowlist are applied; everything else is returned in skipped with the reason, and must be applied by hand. Never overwrites a value that is wired to a variable or expression. Returns content — it does not write to disk.

Inputs: fixes (required), content (required). Returns: object

check_complianceMap findings to compliance frameworksA

Map Terraform findings to the compliance controls they speak to: SOC 2, ISO 27001, NIST 800-53, PCI-DSS, and the regulatory overlays DORA, NIS2, Saudi NCA Cloud Cybersecurity Controls and UAE NESA/SIA. Pass findings from scan_terraform, or files to scan and map in one call. Returns control mappings — evidence for an audit, never an attestation of compliance. Always relay the returned caveat to the user; do not present the result as a compliance verdict.

Inputs: files, findings, frameworks. Returns: object

explain_findingExplain a finding and get its exact fixA

Get the full remediation for one finding from scan_terraform: what is wrong, the exact Terraform to fix it, and whether it is safe to apply mechanically. Call this for every finding you intend to fix instead of guessing the fix yourself.

Inputs: check_id (required), title, resource_address. Returns: object

framework_coverageFramework coverage, including what cannot be evidencedA

For one regulatory framework (DORA, NIS2, NCA-CCC, NESA-IAS), list every article with whether automated configuration scanning can evidence it. Use this when the user asks how much of a regulation the tool covers — the not-evidenced articles are part of the honest answer and must be shown.

Inputs: framework (required). Returns: object

org_requirementsGet the organization's rules for a resource typeA

Get this organization's own infrastructure policy requirements for a resource type — approved regions, required tags, mandatory settings — BEFORE writing the Terraform. Call this first whenever you are about to create a resource, so the code satisfies company policy on the first attempt rather than being corrected afterwards. Returns an empty, explanatory result when no organization policy is configured, which is normal and not an error.

Inputs: provider, resource_type. Returns: object

org_statusCheck whether organization policy is connectedA

Report whether this install is applying an organization's custom policy or running built-in rules only, including the org name and rule count. Use it when the user asks which rules are in force, or why a company rule is not appearing.

Inputs: no named parameters. Returns: object

scan_terraformScan Terraform for security misconfigurationsA

Scan Terraform (HCL) for security misconfigurations and compliance failures. Call this after generating or editing any .tf content, before showing it to the user. Pass files (filename -> HCL content) to scan content that is not saved yet, or paths to scan .tf files and directories on disk. Runs locally; nothing is uploaded. Returns findings ordered by severity, each with a file, line, and whether an exact fix is available.

Inputs: files, paths. Returns: object

secure_templateGet a security-hardened starting templateA

Get a security-hardened Terraform template for a resource type (for example 'aws_s3_bucket', 'aws_db_instance', 'aws_security_group', 'azurerm_storage_account', 'google_storage_bucket'). Prefer this over writing the resource from memory: provider defaults are frequently insecure, and every template here is test-verified to contain no Critical or High findings. Returns the Terraform plus notes on what deliberately still needs the user's input.

Inputs: resource_type (required). Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 8 tools

    Disambiguation4/5

    Each tool has a distinct output and role in the workflow, and the descriptions clarify boundaries well. The only mild overlap is check_compliance being able to scan files itself, which slightly overlaps scan_terraform, but the stated purposes remain clear.

    Naming Consistency3/5

    Names mix imperative verb_noun patterns like scan_terraform, explain_finding, and apply_fixes with noun-phrase names like framework_coverage, org_requirements, and org_status. All names are readable and consistently snake_case, but there is no single predictable naming convention across the set.

    Tool Count5/5

    Eight tools is a well-scoped count for this server's purpose. Each tool contributes to a clear workflow covering policy lookup, template generation, scanning, remediation, compliance mapping, and runtime status.

    Completeness4/5

    The tool surface covers the main Terraform security workflow end to end: plan, generate, scan, explain, fix, and map to compliance frameworks. Minor gaps exist, such as no way to enumerate supported secure_template resource types and framework_coverage only addressing four of the frameworks that check_compliance references.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers