MCP Agent Security Documentation
Overview
MCP Agent implements enterprise-grade security for connecting AI assistants to your APIs. This document covers the security architecture, best practices, and implementation details.
π Security Feature Status
Security Philosophy
Zero-Trust Model
Every AI request is treated as potentially hostile. Thereβs no implicit trust, even for authenticated agents. Every operation is validated against explicit security policies before execution.
Security Without Sacrificing Usability
Strong security shouldnβt mean poor developer experience. MCP Agent provides simple configuration, clear policies, and helpful error messages to make security easy to implement correctly.
Core Security Principles
1. Credential Isolation β
- API keys never reach AI systems
- Credentials stored securely in environment variables
- Only MCP Agent runtime can access credentials
- Credentials injected at execution time, not shared with AI
2. Policy-Based Access Control β
- Every request validated against configured policies
- Fine-grained control by:
- HTTP methods (GET, POST, etc.)
- API paths and patterns
- Allow/deny rules with reasons
- Coming soon:
- Time-based restrictions
- Rate limit enforcement
3. Automatic Data Redaction β
- Sensitive data automatically removed from responses
- Built-in patterns for:
- Social Security Numbers
- Credit card numbers
- API keys and tokens
- Passwords
- Custom redaction patterns supported
- Recursive JSON redaction
4. Comprehensive Audit Logging β
- Every action logged with full context:
- Timestamp
- AI agent identifier
- Requested operation
- Policy evaluation result
- Actual API call made
- Response status
- Data accessed
- Policy violations
- Log rotation and compression
- JSON format for easy parsing
Security Architecture
Request Flow
- AI Request β AI assistant requests API operation via MCP protocol
- Policy Check β Request validated against security policies
- Credential Injection β Secure credentials added from isolated storage
- API Execution β Request sent to target API with monitoring
- Response Filtering β Sensitive data redacted before returning to AI
Defense in Depth
Network Security
- TLS support for secure connections
- HTTPS enforcement
- No external dependencies or telemetry
- Local-only operation mode available
Authentication
- Environment variable support
- Bearer token authentication
- API key management
- Secure credential injection
Authorization
- Role-based access control (RBAC)
- Path-based restrictions
- Parameter validation
- Conditional access policies
Data Protection
- Automatic PII detection
- Field-level filtering
- Response size limits
- Binary data blocking
Policy Configuration
Basic Read-Only Policy
# .mrapids/policy.yaml
policies:
- name: "ai-readonly"
description: "Allow only read operations"
rules:
- allow:
methods: ["GET", "HEAD", "OPTIONS"]
- deny:
methods: ["POST", "PUT", "DELETE", "PATCH"]
Path-Based Restrictions
policies:
- name: "customer-support"
description: "Customer support agent access"
rules:
- allow:
paths:
- "/api/v1/customers/*"
- "/api/v1/orders/*"
methods: ["GET"]
- deny:
paths:
- "/api/v1/admin/*"
- "/api/v1/billing/*"
Multi-Environment Configuration
environments:
development:
base_url: "https://api-dev.example.com"
policy: "dev-policy"
production:
base_url: "https://api.example.com"
policy: "prod-readonly"
Rate Limiting (Configuration)
# Rate limiting configuration available
# Enforcement coming in future update
policies:
- name: "rate-limits"
description: "Configure request limits"
rules:
- allow:
methods: ["GET", "POST"]
limits:
requests_per_minute: 60
requests_per_hour: 1000
Parameter Validation
policies:
- name: "parameter-safety"
description: "Validate request parameters"
rules:
- allow:
paths: ["/api/v1/search"]
parameters:
limit:
type: "integer"
min: 1
max: 100
query:
type: "string"
max_length: 200
pattern: "^[a-zA-Z0-9\\s]+$"
Best Practices
For Administrators
-
Enable Audit Logging
logging: level: "info" audit: true destination: "syslog" format: "json" -
Rotate Credentials Regularly
- Set up quarterly rotation reminders
- Use unique credentials per environment
- Monitor credential usage patterns
-
Monitor AI Behavior
- Set up alerts for unusual request patterns
- Track error rates and policy violations
- Review audit logs weekly
-
Implement Least Privilege
- Start with minimal permissions
- Add access as needed
- Document why each permission exists
For Developers
-
Test Policies Thoroughly
# Test policy evaluation mrapids-agent policy test --request sample.json # Dry run mode mrapids-agent start --dry-run -
Version Control Policies
- Store policies in git
- Use PR reviews for policy changes
- Tag policy versions with releases
-
Handle Errors Gracefully
- Provide clear error messages to AI
- Log detailed errors for debugging
- Never expose internal details
Security Incident Response
-
Immediate Actions
- Identify affected API endpoints
- Review recent audit logs
- Check for policy violations
-
Containment
- Revoke compromised credentials
- Update policies to block attack
- Enable enhanced logging
-
Recovery
- Rotate all credentials
- Review and update policies
- Notify affected users
-
Post-Incident
- Document lessons learned
- Update security procedures
- Implement additional monitoring
Compliance
SOC 2 Type II
- Comprehensive audit trails
- Access control documentation
- Change management procedures
- Security monitoring
GDPR
- Data minimization by default
- PII automatic redaction
- Right to erasure support
- Processing activity logs
HIPAA
- PHI data protection
- Encryption in transit
- Access logging
- Minimum necessary access
PCI DSS
- Secure credential storage
- No credit card data in logs
- Access control enforcement
- Regular security updates
Security FAQ
Q: Can AI see my API credentials? A: No. Credentials are stored securely in your OS keychain and are only accessed by the MCP Agent runtime. AI never sees actual credentials.
Q: What happens if AI tries to delete data? A: Operations are blocked by policy. By default, only GET requests are allowed. Any destructive operations must be explicitly enabled in your policy.
Q: How are responses filtered? A: MCP Agent automatically detects and redacts sensitive patterns like SSNs, credit cards, and API keys. You can add custom patterns for your specific needs.
Q: What limits can I set on AI access? A: Currently, you can restrict by HTTP methods and API paths. Rate limiting and time-based restrictions are configured in policies with enforcement coming in a future update.
Q: Is the audit log tamper-proof? A: Audit logs are append-only and can be sent to external SIEM systems for tamper-proof storage and analysis.
Q: How do I report security issues? A: Email security@microrapid.io (PGP key available). We respond within 24 hours and provide updates throughout the resolution process.
Advanced Topics
Custom Redaction Patterns
redaction:
patterns:
- name: "employee_id"
pattern: "EMP[0-9]{6}"
replacement: "[EMPLOYEE_ID]"
- name: "internal_api_key"
pattern: "sk_[a-zA-Z0-9]{32}"
replacement: "[REDACTED_KEY]"
Multi-Environment Setup
environments:
development:
base_url: "https://api-dev.company.com"
policy: "dev-policy"
production:
base_url: "https://api.company.com"
policy: "prod-readonly"