Skip to main content
Glama
Governed MCP Starter

Governed MCP Starter

by skarthik1710

Governed MCP Starter

A vendor-neutral, secure-by-default reference starter for enterprise AI agent tool servers built around the Model Context Protocol (MCP).

Core design principle: Rules give the verdicts, AI advises, and people approve every change.

Why This Exists

Enterprise AI agents that inspect collaboration suites, directories, or financial systems often need powerful admin-level read access. Giving raw credentials, unmasked PII, and inconsistent authorization logic to every agent is a risk no enterprise security team accepts.

This starter demonstrates a reusable governed tool boundary where:

  1. Agents never hold upstream credentials — only a small, auditable, read-only tool server does.

  2. Authorization fails closed — an Open Policy Agent (Rego) policy checks caller role, tenant clearance, tool allowlist, and READ-only scope before every call. If the policy engine is unreachable, the call is denied.

  3. Identities are pseudonymised before the model sees data — an HMAC-SHA256 keyed pseudonymizer + strict field allowlist strips names, emails, and phone numbers at the tool boundary.

  4. Every call is recorded in a tamper-evident audit chain — hash-chained, content-free entries detect post-hoc modification.

  5. Operators have an immediate kill switch — global or per-tool halts stop agent tool execution cleanly.

  6. Controls are enforced by automated contract tests in CI, not by convention.

Related MCP server: governed-mcp

Architecture

flowchart LR
    Agent["AI Agent / LLM"] -->|"Verified CallerContext"| KS{"Kill Switch"}
    KS -->|"Halted"| Audit["Hash-Chained Audit Log"]
    KS -->|"Active"| OPA{"OPA Policy Sidecar<br/>(Fail-Closed Rego)"}
    OPA -->|"DENY / Unreachable"| Audit
    OPA -->|"ALLOW (READ-only)"| Audit
    OPA -->|"ALLOW"| Data["Read-Only Enterprise Store"]
    Data -->|"Raw Records"| Pseudo["Keyed Pseudonymizer +<br/>Field Allowlist"]
    Pseudo -->|"Pseudonymised Snapshot<br/>(Zero PII)"| Agent

Quick Start (No API Keys Required)

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

# Run the security contract test suite
pytest -v

# Run the end-to-end CLI walkthrough
PYTHONPATH=src python3 -m governed_mcp.demo

To expose the gateway as a live FastMCP server:

pip install -e ".[mcp]"
from governed_mcp import (
    GovernedToolGateway,
    HashChainedAuditLog,
    KeyedPseudonymizer,
    KillSwitch,
    OPAPolicyClient,
    create_fastmcp_server,
)

gateway = GovernedToolGateway(
    policy=OPAPolicyClient(),  # talks to pod-local OPA sidecar; fails closed if unreachable
    pseudonymizer=KeyedPseudonymizer(b"replace-with-vault-secret-32byte"),
    audit_log=HashChainedAuditLog(),
    kill_switch=KillSwitch(),
)
mcp = create_fastmcp_server(gateway)

Security Contract Tests Included

Control

Contract Verified in tests/test_contracts.py

Zero PII leakage

Raw names, emails, and phone numbers never appear in agent-facing payloads; only subject_id + allowlisted fields are returned.

Fail-closed policy

Missing roles, uncleared tenants, write attempts, and unreachable OPA sidecars all deny by default.

Kill switch

Global and per-tool halts immediately block execution and record HALTED in the audit trail.

Tamper-evident audit

Hash-chain verification passes on intact logs and fails immediately if any historical entry is modified.

Tenant isolation

Pseudonyms are deterministic within a tenant and distinct across tenants.

License

MIT — © 2026 Karthikeyan Selvam

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables a language model to safely query internal services through a closed set of read-only, schema-validated tools, with full auditing and refusal logging.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to query a read-only data surface through typed tools, enforcing caller-specific row access, field masking, and withheld-row disclosure so they can retrieve entitled information without writes or silent data leakage.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to safely query SQL databases through read-only tools for describing entities, reading records, and aggregating records, with view-based access and fail-closed per-user row-level security.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to safely explore and query SQL databases through read-only, AST-checked SQL, database-enforced read-only transactions, timeouts, row caps, PII masking, and audit logging.
      MIT