Enterprise Security Monitoring SDK for AI Agents - Secure any AI agent in just 3 lines of code with real-time threat detection, behavioral analysis, and unified reporting that combines logs and insights into a single comprehensive file
Project description
Agent Sentinel
Enterprise Security Monitoring SDK for AI Agents
Secure any AI agent in just 3 lines of code with real-time threat detection, behavioral analysis, and comprehensive reporting capabilities.
Quick Start
from agent_sentinel import monitor, monitor_mcp
# Monitor regular functions
@monitor
def process_data(data: str) -> str:
return data.upper()
# Monitor MCP tools
@monitor_mcp()
def search_database(query: str) -> str:
return f"Searching for: {query}"
# Use the functions
result = process_data("hello world")
search_result = search_database("user data")
Unified Reporting
Agent Sentinel now provides unified reporting that combines logs, security events, and analysis into a single comprehensive file:
Programmatic Usage
from agent_sentinel.core.sentinel import AgentSentinel
# Initialize with monitoring
sentinel = AgentSentinel(agent_id="my_agent")
# Your monitored functions run here...
# Generate unified report
report_path = sentinel.generate_unified_report()
print(f"Report generated: {report_path}")
# Get report path
report_path = sentinel.get_unified_report_path()
CLI Usage
# Generate unified report
agent-sentinel report --config config.yaml --agent-id my_agent
# With custom output
agent-sentinel report --output my_report.json --format json
Report Contents
The unified report includes:
- 📊 Executive Summary: Status, risk score, security events count
- 🔍 Threat Analysis: Detailed breakdown of detected threats
- 📈 Performance Metrics: Monitoring statistics and performance data
- 💡 Recommendations: Actionable security recommendations
- 📝 Session Logs: Real-time monitoring logs
- 🛡️ Security Events: Detailed security event information
Report Structure
{
"metadata": {
"agent_id": "my_agent",
"generated_at": "2025-07-13T09:12:39.375674+00:00",
"report_version": "1.0"
},
"summary": {
"status": "CLEAN|WARNING|CRITICAL",
"total_security_events": 0,
"risk_score": 0.0,
"monitoring_duration": 0.0
},
"threat_analysis": {
"total_threats": 0,
"threat_breakdown": {},
"severity_distribution": {},
"risk_score": 0.0
},
"recommendations": [
"No security threats detected. Continue monitoring for best practices."
],
"performance_metrics": {
"total_events": 0,
"events_by_type": {},
"average_confidence": 0.0
},
"security_events": [],
"session_logs": []
}
Installation
pip install agent-sentinel
What It Does
Agent Sentinel automatically detects and blocks 20+ threat types including:
- SQL Injection - Pattern-based detection of malicious SQL queries
- XSS Attacks - Cross-site scripting attack prevention
- Command Injection - Shell command injection protection
- Prompt Injection - LLM prompt manipulation attempts
- Data Exfiltration - Unauthorized data access patterns
- Behavioral Anomalies - Unusual agent behavior patterns
Usage
Basic Monitoring
from agent_sentinel import monitor, monitor_mcp
# Monitor regular functions and methods
@monitor
def process_user_input(user_data: str) -> str:
return f"Processed: {user_data}"
# Monitor MCP (Model Context Protocol) tools
@monitor_mcp()
def search_web(query: str) -> dict:
return {"results": "web search results"}
# Automatic threat detection and reporting
result = process_user_input("safe data")
search_results = search_web("test query")
Advanced Configuration
from agent_sentinel import Sentinel
# Initialize with custom configuration
sentinel = Sentinel(
agent_id="production_agent",
environment="production"
)
# Monitor with custom settings
@sentinel.monitor
def critical_operation(data: dict) -> dict:
return {"status": "success", "data": data}
Session-Based Monitoring
from agent_sentinel import Sentinel
sentinel = Sentinel(agent_id="session_agent")
# Monitor entire user sessions
with sentinel.monitor_session("user_session_123"):
result1 = process_query(query)
result2 = generate_response(result1)
result3 = format_output(result2)
Key Features
Real-Time Threat Detection
- Automatic detection of 20+ threat types
- Zero false positives in production testing
- <0.05ms average detection latency
- 40,000+ operations/second throughput
Enterprise Security
- Circuit breaker pattern for failure protection
- Structured logging with compliance tags (GDPR, SOC2, HIPAA)
- Performance monitoring and resource tracking
- Multi-agent coordination security
Framework Integration
- LangChain: Direct agent class monitoring
- AutoGen: Multi-agent conversation security
- Custom Frameworks: Universal decorator support
- MCP Tools: Specialized Model Context Protocol monitoring
Performance
Production Tested
- Browser MCP Agent: 49,508 ops/sec, 100% detection rate
- GitHub MCP Agent: 41,048 ops/sec, 100% detection rate
- Financial Coach Agent: 98,319 ops/sec, 100% detection rate
- Multi-Agent Researcher: 45,246 ops/sec, 100% detection rate
Security Analytics
# Get comprehensive security insights
metrics = sentinel.get_security_metrics()
{
"total_threats_blocked": 1247,
"detection_rate": 100.0,
"avg_response_time": "0.05ms",
"threat_breakdown": {
"sql_injection": 423,
"xss_attack": 312,
"prompt_injection": 289
}
}
CLI Tools
# Real-time monitoring
agent-sentinel monitor --agent-id my_agent
# Security audit
agent-sentinel audit --config config.yaml
# Performance analysis
agent-sentinel analyze --time-range 24h
# Export reports
agent-sentinel export --format json --output report.json
Configuration
Zero Configuration (Recommended)
# Works out of the box
from agent_sentinel import monitor, monitor_mcp
@monitor
def my_function():
pass
Custom Configuration
# config.yaml
agent_id: "production_agent"
environment: "production"
detection:
enabled: true
confidence_threshold: 0.8
logging:
level: "INFO"
format: "json"
sentinel = Sentinel(config_path="config.yaml")
Security & Compliance
- GDPR: Data privacy and retention controls
- SOC2: Audit trails and access controls
- HIPAA: Healthcare data protection
- Local processing by default
- Configurable data retention policies
- Encryption for sensitive data
Use Cases
- AI Agent Security: LLM prompt injection protection, tool usage monitoring
- Enterprise Applications: Compliance monitoring, audit trail generation
- Development & Testing: Security testing automation, behavior analysis
Architecture
Modular Design
agent_sentinel/
├── core/ # Core SDK functionality
├── detection/ # Threat detection engines
├── enterprise/ # Enterprise features
├── infrastructure/ # Monitoring & metrics
├── intelligence/ # Threat intelligence
├── logging/ # Structured logging
├── security/ # Security utilities
├── services/ # Core services
└── wrappers/ # Agent integration
Plugin Architecture
- Custom detectors: Add domain-specific threat detection
- Intelligence sources: Integrate external threat feeds
- Export formats: Custom data export formats
- Notification systems: Slack, email, webhook integrations
Development Setup
Prerequisites
- Python 3.9+
- Git
- Virtual environment (recommended)
Installation
# Clone repository
git clone https://github.com/agentsentinel/agent-sentinel.git
cd agent-sentinel
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e .[dev]
# Install pre-commit hooks
pre-commit install
Development Dependencies
# Install all development tools
pip install -e .[dev,test,docs]
# Or install individually
pip install -e .[dev] # Development tools (black, isort, mypy, etc.)
pip install -e .[test] # Testing framework (pytest, coverage, etc.)
pip install -e .[docs] # Documentation tools (sphinx, etc.)
Testing
Run Test Suite
# Run all tests
pytest
# Run with coverage
pytest --cov=agent_sentinel --cov-report=html
# Run specific test categories
pytest -m unit # Unit tests
pytest -m integration # Integration tests
pytest -m security # Security tests
pytest -m slow # Slow running tests
Security Validation
# Run comprehensive security tests
python test_comprehensive_integration.py
# Test with real agents
python test_real_agents_integration.py
# Performance benchmarks
python test_performance_benchmarks.py
Code Quality
# Format code
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
# Linting
flake8 src/ tests/
bandit -r src/
Contributing
We welcome contributions! Please see our Contributing Guide for detailed information.
Quick Contribution Guide
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow PEP 8 style guidelines
- Add type hints to all functions
- Write comprehensive tests
- Update documentation for new features
- Ensure all tests pass before submitting
Testing Your Changes
# Run the full test suite
pytest
# Check code quality
pre-commit run --all-files
# Build documentation
cd docs && make html
Documentation
Building Documentation
# Install documentation dependencies
pip install -e .[docs]
# Build documentation
cd docs
make html
# View documentation
open _build/html/index.html
Documentation Structure
- User Guide: Getting started and basic usage
- API Reference: Complete API documentation
- Examples: Code examples and tutorials
- Architecture: System design and components
- Deployment: Production deployment guides
Deployment
Production Deployment
# Install production version
pip install agent-sentinel
# Configure environment
export AGENT_SENTINEL_ENVIRONMENT=production
export AGENT_SENTINEL_AGENT_ID=your_agent_id
# Run with monitoring
agent-sentinel monitor --config production.yaml
Docker Deployment
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["agent-sentinel", "monitor"]
Kubernetes Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent-sentinel
spec:
replicas: 3
selector:
matchLabels:
app: agent-sentinel
template:
metadata:
labels:
app: agent-sentinel
spec:
containers:
- name: agent-sentinel
image: agentsentinel/agent-sentinel:latest
ports:
- containerPort: 8080
Support
Get Help
- Documentation: Comprehensive guides and API reference
- GitHub Issues: Bug reports and feature requests
- Discord Community: Community support and discussions
- Enterprise Support: Professional support and consulting
Quick Links
- Dashboard Demo: Live security dashboard
- Security Playground: Test threat detection
- Performance Benchmarks: Latest performance data
- Threat Intelligence Feed: Real-time threat data
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG.md for a detailed history of changes.
Ready to secure your AI agents? Get started in 30 seconds:
pip install agent-sentinel && python -c "
from agent_sentinel import monitor, monitor_mcp
print('Agent Sentinel is ready!')
"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_sentinel-0.1.8.tar.gz.
File metadata
- Download URL: agent_sentinel-0.1.8.tar.gz
- Upload date:
- Size: 169.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a53caabe62750beea6f39b8fcdcc3aa42274b2c44337a9d4432f90a3b507181
|
|
| MD5 |
f872bcb5d07c907243417acd7b34b02f
|
|
| BLAKE2b-256 |
2d5e05b13eae90dad139ed86fef008ca366823775e108b0604132f2366020239
|
File details
Details for the file agent_sentinel-0.1.8-py3-none-any.whl.
File metadata
- Download URL: agent_sentinel-0.1.8-py3-none-any.whl
- Upload date:
- Size: 187.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf7d0139e4ad3643864ccc86b8c2ccd7624417a34ab1c5cddb49afed1b0e22f6
|
|
| MD5 |
f820fe8ffb16a29c7ee0c1afc262e934
|
|
| BLAKE2b-256 |
4145e10b178355a46d42d8c005dfd0fe1083cf3af95502daa1a04adb1be452d3
|