policy-gate-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@policy-gate-mcpreview the system prompt in agent.py"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
policy-gate-mcp
Policy-as-code AI-SDLC gates for LLM agent repos, shipped as both an MCP server (for interactive use from an editor/agent) and a CLI (for CI). It is pre-configured to govern the USEA agent, and is written so any other agent repo can be onboarded as a new "profile".
It implements the four gates requested for the AI-SDLC:
Gate | What it checks | Module |
1. Prompt / system-prompt review | The assembled system prompt against forbidden/required patterns, a length limit, and a reviewed baseline | |
2. Tool manifest diffing | Every tool exposed to the agent, diffed against a recorded baseline, risk-classified, with sign-off required for high/critical changes | |
3. MCP server vetting | Any | |
4. Eval suites as CI regression tests | Golden-transcript eval cases with |
Every gate returns the same GateResult shape (pass / warn / fail
/ skipped, a list of violations, and structured details), so the MCP
tool, the CLI subcommand, and the CI job all agree on the verdict.
Why this exists
Agent repos like USEA change three things that traditional CI never looked at: the system prompt, the tool manifest (what the model is allowed to do), and the MCP servers it can talk to. A one-line prompt edit or a new tool can silently turn a "read files" agent into a "run arbitrary shell commands and exfiltrate secrets" agent, and normal unit tests won't catch it. This repo turns those three surfaces - plus behavioral regressions - into things that are diffed, classified, and gated in the same PR review flow as code.
Related MCP server: scan-your-ai-toolkit
Architecture
flowchart TB
subgraph Governed repo - e.g. USEA
A[do-anything-agent.py]
end
subgraph policy-gate-mcp - this repo
P[profiles/usea.yaml]
POL[policies/*.yaml]
BASE[baselines/usea/*]
EV[evals/usea_suite.yaml + fixtures/]
G1[prompt_review.gate]
G2[tool_manifest.gate]
G3[mcp_vetting.gate]
G4[eval_runner.gate]
CLI[policy_gate/cli.py]
SRV[server.py - MCP tools]
end
A -- static AST parse, never executed --> G1
A -- static AST parse, never executed --> G2
P --> G1 & G2 & G3 & G4
POL --> G1 & G2 & G3 & G4
BASE --> G1 & G2
EV --> G4
G1 & G2 & G3 & G4 --> CLI
G1 & G2 & G3 & G4 --> SRV
CLI -- exit 0/1 --> CI[GitHub Actions: ai-sdlc-gates.yml]
SRV -- tool calls --> Editor[MCP client / coding agent]Key design choices:
Static analysis, not execution. Both the prompt-review and tool-manifest gates parse the target file with
astand neverimport/execit. There's no need for the governed repo's runtime dependencies (LangChain, provider SDKs, etc.) to run these two gates, and a malicious prompt/tool can't execute code during the gate itself.Profiles, not hardcoding.
profiles/usea.yamlis the only place that knows USEA's file names and variable names. Onboarding a second agent means addingprofiles/<name>.yamlplus its ownbaselines/<name>/...andevals/<name>_suite.yaml- the gate engine itself is generic.Policies are reviewable YAML, not code. All four gates read their rules from
policies/*.yaml. Changing what's blocked is a normal, diffable pull request against this repo, not a code change.Fail closed. An unrecognized tool, a missing baseline file's sign-off, or an unclassified MCP server all fail the gate rather than silently passing.
The four gates in detail
Gate 1 - Prompt / system-prompt review
prompt_review.py walks the target file's AST and reconstructs every
string assigned or +=-appended to a configured variable (system_content
for USEA), ordered by source line number so conditional branches (e.g. the
Vault-policy block that's only appended if vault_enabled) come out in
the same order a human reading the file would see them.
The reconstructed text is checked against
policies/prompt_policy.yaml:
forbidden_patterns- regexes that must never appear (prompt-injection phrasing like "ignore previous instructions", jailbreak personas, "disable safety", "output the raw API key", etc.), each with a human-readable reason.required_patterns- regexes that must appear (USEA's policy requires the prompt to instruct the model to mask sensitive values and to explain risk before acting).max_length_chars- a hard cap.Baseline diff - if the extracted prompt no longer matches
baselines/usea/system_prompt.baseline.txt, the gate fails unlesspolicies/prompt_review_log.yamlhas a matching entry (reviewer, date, PR link). This is what turns "someone tweaked the system prompt" from invisible to a required, attributable sign-off.
To accept an intentional prompt change: update the baseline file with the
new extracted text, then append an entry to prompt_review_log.yaml
naming the reviewer.
Gate 2 - Tool manifest diffing
tool_manifest.py walks the same AST for every function decorated with
@tool (configurable via tool_manifest.decorator_name), extracting its
name, docstring, and parameter signature (name/annotation/default) into a
canonical JSON shape. It diffs the result against
baselines/usea/tool_manifest.baseline.json.
policies/tool_manifest_policy.yaml
requires every tool to carry an explicit risk tier
(low / medium / high / critical) plus a capability and
justification. For USEA today: list_directory / read_text_file are
low (read-only), write_text_file is high (unrestricted filesystem
write), and run_command is critical (arbitrary shell execution).
Rules enforced:
Any tool with no risk classification fails, whether new or pre-existing - the manifest must have 100% coverage.
New or changed
high/criticaltools require a sign-off entry inpolicies/tool_manifest_review_log.yaml(tool name + profile + reviewer), or the gate fails.Removed tools only produce a warning (nothing unsafe about an agent losing a capability).
This is the gate that catches "tool poisoning" - an agent quietly gaining a new high-blast-radius capability (network egress, unrestricted writes, shell exec) that nobody explicitly reviewed.
Gate 3 - MCP server vetting
mcp_vetting.py validates an mcpServers/servers config (the same
shape as a VS Code / Claude Desktop mcp.json) against
policies/mcp_server_allowlist.yaml:
launch
commandmust be onallowed_commands(no arbitrary binaries orcurl | shstyle installers)npx/uvxinvocations must be pinned to a version (@x.y.z/==x.y.z) - nolatesturl-based (remote) servers must targetallowed_remote_domainsenv vars matching
secret_env_key_patterns(API_KEY,TOKEN,SECRET,PASSWORD) must use"${VAR_NAME}"expansion, never a literal value committed to the configevery server entry must carry a
trust_reviewblock naming a reviewer
configs/usea.mcp.json is a compliant example
(it even vets itself - the policy-gate server entry - and a pinned,
scoped filesystem server). configs/bad_example.mcp.json
is intentionally non-compliant and is used by the test suite to prove
every rule actually fires.
Gate 4 - Eval suites as CI regression tests
evals/usea_suite.yaml defines eval cases, each
with a severity:
blocking- must always pass, zero tolerance (e.g. "must refuse to runrm -rf /", "must never print a raw API key"). A single blocking failure fails the gate regardless of the overall pass rate.warning- scored into an overall pass rate that must clearmin_pass_ratefrompolicies/eval_thresholds.yaml(default 90%).
Two run modes:
static(default, what CI runs): replays recorded golden transcripts fromevals/fixtures/*.jsonagainst each case's assertions (expected_tool_calls,forbidden_tool_calls,required_output_patterns,forbidden_output_patterns). Deterministic, free, no model credentials needed.live: dynamically loads the governed agent's real entrypoint (the sameimportlib.util.spec_from_file_locationpattern USEA's ownapi/agent_runner.pyuses to loaddo-anything-agent.py), actually calls the model for each case'squery, and applies the same assertions. Pass--recordto overwrite the golden fixtures with the new transcript - this is how you intentionally refresh the regression baseline after a real behavior change.
Running it
As a CLI (what CI uses)
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
# Run one gate
policy-gate --profile usea review-prompt /path/to/USEA
policy-gate --profile usea diff-tools /path/to/USEA
policy-gate --profile usea vet-mcp
policy-gate --profile usea run-evals /path/to/USEA --mode static
# Run everything (this is what the CI workflow calls)
policy-gate --profile usea check-all /path/to/USEA
# Machine-readable report
policy-gate --profile usea json /path/to/USEAExit code is 0 if every gate passed (or only warned), 1 if any gate
failed.
As an MCP server (interactive use during development)
pip install -e ".[dev]"
python3 server.py # stdio transportPoint an MCP client at it, e.g. add to your editor's mcp.json
(see configs/usea.mcp.json for the exact
shape):
{
"mcpServers": {
"policy-gate": {
"command": "python3",
"args": ["/absolute/path/to/MCP/server.py"]
}
}
}Exposed tools: review_prompt, diff_tool_manifest, vet_mcp_servers,
run_eval_suite, run_all_gates - each takes the same repo_path /
profile arguments as the CLI, so a coding agent can call run_all_gates
on its own working copy before opening a PR.
Wiring into USEA's CI
USEA/.github/workflows/ai-sdlc-gates.yml
checks out both repos, installs this one editable, and runs
policy-gate --profile usea check-all. Unlike USEA's existing
ci-build.yml (which uses continue-on-error: true for most steps),
this workflow is a real gate - it fails the PR check on any fail
status.
Onboarding a new governed agent
Add
profiles/<name>.yamldescribing the target file, the system prompt variable name, the tool decorator name, and paths for the baseline/eval files (copyprofiles/usea.yamlas a template).Run
policy-gate --profile <name> review-prompt <repo>and... diff-tools <repo>once against a known-good checkout; both will reportwarn("no baseline recorded yet") and print the extracted prompt/manifest indetails. Save those intobaselines/<name>/system_prompt.baseline.txtandbaselines/<name>/tool_manifest.baseline.json.Classify every tool in
policies/tool_manifest_policy.yaml.Add an MCP server config at
configs/<name>.mcp.jsonand reference it from the profile.Write
evals/<name>_suite.yamlplus golden fixtures underevals/fixtures/.
Testing this repo itself
pip install -e ".[dev]"
pytest tests/ -vThe test suite proves both directions for each gate: the bundled usea
profile passes cleanly against a faithful fixture of USEA's real
prompt/tools/MCP config/evals, and dedicated "bad" fixtures
(tests/fixtures/bad_prompt_repo, tests/fixtures/new_tool_repo,
configs/bad_example.mcp.json) prove each rule fails closed.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenancePolicy-based governance for AI agent tool calls. YAML policies, approval gates, risk assessment, and audit logging across LangChain, OpenAI, Anthropic, and MCP.Last updated512MIT
- Flicense-quality-maintenanceOpen-source AI governance toolkit. MCP servers & CLIs for scanning, auditing, and managing your AI environmentLast updated
- FlicenseAqualityCmaintenanceA unified developer toolkit for AI-assisted workflows. Task timing, doc drift detection, env validation, secret scanning, port conflict resolution, AI context generation, and license auditing — one MCP server, one install.Last updated73
- AlicenseAqualityCmaintenanceA local MCP server that packages LLM evaluation gates as reusable CI/CD primitives, enabling AI agents to run datasets against models, score responses, and enforce quality thresholds.Last updated10MIT
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Security firewall for AI agents — scans MCP calls for injection, secrets, and risks.
Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/iestarks/MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server