PolicyGuard MCP Server

Security & Governance MCP Server for AI Agents

README.md

PolicyGuard

Security & Governance MCP Server for AI Agents

PolicyGuard is an MCP (Model Context Protocol) server that provides policy-based access control, incident tracking, and compliance monitoring for AI agents.

Note: This project demonstrates working integration with kagent (AI agent platform) and can be extended with kgateway (API gateway) for additional network-level security.


Overview

As AI agents become more autonomous, organizations need controls to govern their behavior. PolicyGuard is my first MCP server project - built to explore how security and governance can be implemented at the MCP layer.

The Problem

AI agents can call any tool they have access to. Without governance:

  • Agents might perform destructive operations
  • No audit trail of agent actions
  • No way to enforce security policies
  • No visibility into compliance

The Solution

PolicyGuard adds a security layer that agents call before taking action:

User Request → AI Agent → PolicyGuard (validate_action) → Allowed/Denied

Features

Feature Description
Policy Enforcement Validate actions against security rules
Trust Levels low, medium, high, admin hierarchy
Pattern Matching Wildcard patterns like delete_*, *_production
Auto-Registration Unknown agents get minimal trust
Incident Tracking Automatic violation logging
Audit Trail Complete action history
Compliance Dashboard Security metrics at a glance

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         AI Agent / LLM                          │
│                                                                 │
│  "Before any action, call validate_action to check permission" │
└─────────────────────────────────────────────────────────────────┘
                              │
                              │ MCP Protocol
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                     PolicyGuard MCP Server                      │
│                                                                 │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐             │
│  │  validate   │  │   create    │  │   report    │             │
│  │   action    │  │   policy    │  │  incident   │             │
│  └─────────────┘  └─────────────┘  └─────────────┘             │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐             │
│  │  register   │  │  get_audit  │  │    get      │             │
│  │   agent     │  │    log      │  │ compliance  │             │
│  └─────────────┘  └─────────────┘  └─────────────┘             │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
                    ┌───────────────────┐
                    │   JSON Storage    │
                    │   (policies,      │
                    │    agents,        │
                    │    audit_log,     │
                    │    incidents)     │
                    └───────────────────┘

MCP Tools

PolicyGuard exposes 6 tools via MCP:

1. `validate_action` ⭐ Primary Tool

Check if an action is allowed before executing it.

{
  "action_type": "tool_call",
  "target": "delete_records",
  "agent_id": "my-agent"
}

Response:

{
  "action_id": "act_a1b2c3d4e5f6",
  "allowed": false,
  "reason": "Delete operations require admin trust level"
}

2. `register_agent`

Register an agent with a trust level.

{
  "agent_id": "data-processor",
  "name": "Data Agent",
  "trust_level": "medium"
}

3. `create_policy`

Create security rules.

{
  "policy_id": "block-deletes",
  "name": "Block Deletes",
  "rules": "[{\"condition\": {\"tool_pattern\": \"delete_*\"}, \"action\": \"deny\"}]"
}

4. `get_audit_log`

Query action history.

5. `get_compliance_status`

Get security dashboard metrics.

6. `report_incident`

Manually report security incidents.


Quick Start

Prerequisites

  • Python 3.10+
  • pip

Local Installation

# Clone
git clone https://github.com/PrateekKumar1709/policy

Tools 6

validate_actionCheck if an action is allowed before executing it.
register_agentRegister an agent with a trust level.
create_policyCreate security rules.
get_audit_logQuery action history.
get_compliance_statusGet security dashboard metrics.
report_incidentManually report security incidents.

Try it

Register my new data-processor agent with a medium trust level.
Create a new policy that denies any tool pattern starting with delete_.
Validate if the agent 'my-agent' is allowed to perform the 'delete_records' action.
Show me the current compliance status and security metrics.
Retrieve the audit log to review recent agent actions.

Frequently Asked Questions

What are the key features of PolicyGuard?

Policy enforcement against security rules. Trust level hierarchy (low, medium, high, admin). Pattern-based matching for tool access. Automatic incident tracking and logging. Compliance dashboard for security metrics.

What can I use PolicyGuard for?

Preventing AI agents from performing destructive operations in production environments. Maintaining a comprehensive audit trail of all actions taken by autonomous agents. Enforcing security policies based on agent trust levels. Monitoring and reporting security incidents involving AI agent behavior.

How do I install PolicyGuard?

Install PolicyGuard by running: git clone https://github.com/PrateekKumar1709/policyguard

What MCP clients work with PolicyGuard?

PolicyGuard works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep PolicyGuard docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare