Sentinel MCP Data Governance Agent
A data governance agent that audits PostgreSQL databases through controlled MCP tools for schema inspection, null profiling, and anomaly detection.
README
Sentinel MCP Data Governance Agent
Sentinel is a autonomous data governance agent that audits a PostgreSQL database through the Model Context Protocol (MCP). Instead of giving the LLM direct database access, the project exposes a controlled FastMCP bridge with purpose-built tools for schema inspection, null profiling, and anomaly detection.
The demo seeds an intentionally dirty raw_inventory table, asks an OpenAI-powered agent to inspect it through MCP tools, and writes a Markdown audit report to LATEST_AUDIT.md.
What It Demonstrates
- A Python MCP client that follows a ReAct-style Reason -> Act -> Observe workflow.
- A FastMCP server that acts as a governance bridge between the agent and PostgreSQL.
- SQLAlchemy-backed tools for safe, structured database inspection.
- Data quality checks for missing emails, negative inventory counts, and duplicate SKUs.
- A generated Data Health Audit with remediation SQL.
Architecture
flowchart LR
U[User question] --> A[Python Agent<br/>MCP Client]
A -->|tools/list and tools/call| M[FastMCP Server<br/>Sentinel-Bridge]
M -->|SQLAlchemy queries| DB[(PostgreSQL 16<br/>raw_inventory)]
DB -->|schema and quality metrics| M
M -->|structured MCP tool results| A
A -->|OpenAI analysis or local fallback| R[LATEST_AUDIT.md]
MCP Tools
inspect_schema() returns table names and column definitions for structural audits.
get_data_health_sample() returns 100 recent rows from raw_inventory for row-level review.
check_null_ratios(table_name="raw_inventory") returns null counts and percentages for every column.
find_logical_anomalies() returns rows with negative stock_count values and duplicated sku groups.
Project Layout
agent.py # MCP client and ReAct audit workflow
server.py # FastMCP server exposing database audit tools
seed_data.py # Faker-based dirty data generator
docker-compose.yml # PostgreSQL 16 local database
architecture.md # Mermaid architecture diagram
.env.example # Safe environment variable template
Setup
Requirements:
- Windows 11, macOS, or Linux
- Docker Desktop
- Python managed with
uv - An OpenAI API key with available API quota
Create your local environment file:
Copy-Item .env.example .env
Edit .env and replace placeholder values. Do not commit .env.
Install dependencies:
uv sync
Start PostgreSQL:
docker compose up -d
Seed the dirty inventory table:
uv run python seed_data.py
Run the MCP server directly:
uv run python server.py
In another terminal, run the autonomous audit agent:
uv run python agent.py
The agent writes its report to:
LATEST_AUDIT.md
Verify the Seeded Data
docker exec -it sentinel_postgres psql -U sentinel_user -d sentinel_db -c "SELECT COUNT(*) AS negative_stock_rows FROM raw_inventory WHERE stock_count < 0;"
Expected result after seeding:
30
Security Notes
.envis ignored by Git and must never be committed..env.examplecontains placeholders only.- The LLM does not receive raw database credentials directly; it interacts with approved MCP tools.
- The MCP server is the policy boundary where database capabilities are explicitly exposed.
- Rotate any API key that has appeared in logs, screenshots, terminal output, or chat.
Why MCP Instead of Direct SQLAlchemy in the Agent?
MCP gives the LLM a constrained tool interface rather than unrestricted database access. The FastMCP server defines the allowed actions, making the governance boundary explicit and auditable. The same agent can later interoperate with catalogs, policy engines, warehouses, and observability systems through MCP without rewriting the agent around direct database connections.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.