How dorenatwork/mcp-guardian works
MCP Guardian is an initial FastAPI scaffold for an enterprise MCP control-plane gateway. The demonstrated workflow accepts a client POST, checks the HTTP envelope and body size, validates JSON-RPC metadata and protocol version, and returns discovery data or a protocol-safe error; it explicitly does not execute upstream requests. The router also composes named control-plane API areas and health routes, but their implementations are not shown. The graph reflects that limit: those areas are represented as scaffold capabilities, not asserted runtime workflows.
Main entry points: service.py MCP protocol service · handle.py MCP POST handler · urls.py API router · decoder.py JSON-RPC decoder
Components 20
Application and routing
- FastAPI application
main.py - API router
apps/urls.py
MCP request boundary
- Gateway routes
apps/gateway/urls.py - MCP POST handler
apps/gateway/mcp_request/views/post/handle.py - MCP protocol service
apps/gateway/mcp_request/service.py - Discovery parameters
apps/gateway/mcp_request/serializers/requests.py - MCP response models
apps/gateway/mcp_request/serializers/responses.py
Protocol validation
- HTTP envelope checks
infrastructure/mcp/http_transport.py - JSON-RPC decoder
infrastructure/mcp/decoder.py - Mirrored header checks
infrastructure/mcp/header_validation.py - Protocol message models
infrastructure/mcp/models.py - Protocol errors
infrastructure/mcp/errors.py
Shared platform
- Runtime settings
shared/config/settings.py
Control-plane capabilities
- Health routes
apps/monitoring/urls.py - Health endpoints
apps/monitoring/system_health/views - Health status service
apps/monitoring/system_health/service.py - Other control APIs
apps - Models and repositories
data - Provider adapters
infrastructure
Other components
- MCP client
Connections 20
- MCP client → MCP POST handler: POSTs request
apps/gateway/mcp_request/views/post/handle.py - FastAPI application → API router: mounts routes
main.py - API router → Gateway routes: includes router
apps/urls.py - API router → Health routes: includes router
apps/urls.py - API router → Other control APIs: includes routers
apps/urls.py - Gateway routes → MCP POST handler: routes to
apps/gateway/urls.py - MCP POST handler → MCP protocol service: calls
apps/gateway/mcp_request/views/post/handle.py - MCP POST handler → HTTP envelope checks: reads bounded body
apps/gateway/mcp_request/views/post/handle.py - MCP POST handler → MCP response models: serializes errors
apps/gateway/mcp_request/views/post/handle.py - MCP protocol service → HTTP envelope checks: validates envelope
apps/gateway/mcp_request/service.py - MCP protocol service → JSON-RPC decoder: decodes message
apps/gateway/mcp_request/service.py - MCP protocol service → Mirrored header checks: checks metadata
apps/gateway/mcp_request/service.py - MCP protocol service → Discovery parameters: validates discovery
apps/gateway/mcp_request/service.py - MCP protocol service → MCP response models: builds discovery
apps/gateway/mcp_request/service.py - MCP protocol service → Runtime settings: reads configuration
apps/gateway/mcp_request/service.py - JSON-RPC decoder → Protocol message models: creates messages
infrastructure/mcp/decoder.py - JSON-RPC decoder → Protocol errors: raises errors
infrastructure/mcp/decoder.py - HTTP envelope checks → Protocol errors: raises errors
infrastructure/mcp/http_transport.py - Health routes → Health endpoints: routes to
apps/monitoring/urls.py - Health endpoints → Health status service: uses status service