使用说明
Sentinel
Sentinel is an MCP security gateway that intercepts JSON-RPC calls between an AI agent client and MCP servers.
It enforces:
- tool/resource authorization
- intent checks for high-risk tool calls
- PII and secret redaction on both request params and response payloads
What is implemented
- Protocol-aware interception for
list_tools,call_tool,read_resource - Policy engine interface with:
- in-memory rules (
SENTINEL_POLICY_MODE=memory) - OpenFGA check adapter seam (
SENTINEL_POLICY_MODE=openfga)
- in-memory rules (
- Intent validator interface with:
- no-op validator
- HTTP validator for a small external model
- JSON redactor for emails, cards, tokens, secrets, and sensitive key names
- Unit tests for tool filtering, policy denial, intent denial, and redaction
Project layout
cmd/sentinel/main.go
internal/proxy/gateway.go
internal/policy/*
internal/intent/*
internal/scrubber/*
internal/transport/upstream.go
Run
go run ./cmd/sentinel
Required environment variable:
SENTINEL_UPSTREAM_URL(example:http://localhost:9000/mcp)
Common configuration:
SENTINEL_LISTEN_ADDRdefault:8080SENTINEL_POLICY_MODEdefaultmemory(memoryoropenfga)SENTINEL_ALLOW_RULESmemory rules format:user|agent|action|resourceentries separated by commasSENTINEL_HIGH_RISK_TOOLScomma-separated tool namesSENTINEL_INTENT_URLHTTP endpoint for intent validationSENTINEL_INTENT_FAIL_CLOSEDdefaulttrue
OpenFGA options:
SENTINEL_OPENFGA_URLSENTINEL_OPENFGA_STORE_IDSENTINEL_OPENFGA_MODEL_ID
Example memory policy rules
Allow one agent to call only selected tools and read one resource namespace:
SENTINEL_ALLOW_RULES="*|finance-agent|call|tool:get_*,*|finance-agent|read|resource:ledger/*"
MCP endpoint
Send MCP JSON-RPC traffic to:
POST /mcp
Optional context headers:
X-User-IdX-Agent-IdX-Session-IdX-Agent-Trace(reasoning trace passed into intent validation)
Test
go test ./...
Production hardening next
- Add mTLS between Sentinel and MCP servers
- Add authn for incoming agent clients (JWT/mTLS/API key)
- Add decision caching with short TTL
- Add structured logs + OpenTelemetry traces
- Add circuit breakers for intent/OpenFGA dependencies
- Add streaming redaction for large payloads