Concepts
Hooks
Middleware pattern for MCP request processing
Overview
Hooks provide a middleware layer for intercepting and processing MCP requests and responses. They enable you to add custom logic, security rules, or transformations without modifying the underlying MCP servers.
How Hooks Work
Each hook in the chain can:
- Inspect the request/response data
- Modify parameters or results
- Block requests based on custom rules
- Enrich data with additional context
Common Hook Patterns
- Security Filtering: Validate requests against security policies
- Rate Limiting: Control request frequency and volume
- Data Transformation: Modify request/response formats
- Audit Logging: Record all tool interactions
- Content Filtering: Remove or redact sensitive information
In Civic Labs
Hooks power several of our security tools:
- The Pass-through Proxy provides the core hook infrastructure
- The Guardrail Proxy implements security rules as hooks
- Bodyguard can be deployed as a hook for threat detection
Learn More
- Pass-through Proxy - The middleware system that enables hooks
- Guardrail Proxy - Security implementation using hooks