
Autonomous AI-powered cyber defense system using MCP, Gemini 2.0 Flash, Dynatrace observability and MongoDB. Google Cloud Hackathon submission.
Google Cloud Hackathon submission — Autonomous threat detection and remediation orchestrated by Google Cloud Agent Builder (Vertex AI Agent), powered by Gemini 2.0 Flash, Model Context Protocol (MCP), and Dynatrace observability.
Security teams face 30-minute MTTD and 4-hour MTTR for typical incidents. By the time a human analyst detects the attack, writes the firewall rule, and deploys it, the damage is done.
SentinelMCP reduces MTTD to < 30 seconds and MTTR to < 30 seconds by deploying a Google Cloud Agent Builder agent that receives Dynatrace anomaly webhooks, reasons over them with Gemini 2.0 Flash, and invokes real defense tools via MCP — acting on live infrastructure, not just alerting.
Dynatrace webhook → Agent Builder receives alert → Gemini reasons → MCP tools execute → Threat neutralized
1 s 2 s 8 s 15 s 25 s total
The result: an incident lifecycle that previously required a human analyst and 4 hours now completes autonomously in under 30 seconds, with a full audit trail in MongoDB and distributed traces in Jaeger.
┌──────────────────────────────────────────────────────────────────────┐
│ SANDBOX ENVIRONMENT │
│ │
│ ┌─────────────┐ 100–1000 req/s ┌──────────────────────────┐ │
│ │ attacker │ ──────────────────►│ victim-service │ │
│ │ (DDoS/SQLi) │ │ port 8080 │ │
│ └─────────────┘ │ /admin/* control API │ │
│ └────────────┬─────────────┘ │
└───────────────────────────────────────────────────│──────────────────┘
│ metrics + anomaly webhook
┌────────────────────────────────▼─────────────────┐
│ Dynatrace Mock (anomaly engine) │
│ Threat Risk Score → fires POST /alerts/simulate │
└────────────────────────┬─────────────────────────┘
│ webhook
┌─────────────────────────────────▼──────────────────────────┐
│ Google Cloud Agent Builder (Vertex AI Agent) │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Gemini 2.0 Flash ── reasons over threat context │ │
│ │ Tool manifest ── dynamically fetched from MCP │ │
│ │ HITL gate ── halts if confidence < threshold │ │
│ └──────────────────────────────────────────────────────┘ │
└──────────────┬─────────────────────────┬───────────────────┘
│ REST calls │ audit write
┌───────────────▼──────┐ ┌────────────▼──────────┐
│ MCP Server :8001 │ │ MongoDB 7.0 Atlas │
│ 11 real tools │ │ incidents + traces │
└───────────┬──────────┘ └───────────────────────┘
│ acts on live infra
┌───────────▼──────────┐
│ FastAPI :8000 │
│ victim-service :8080│
└──────────────────────┘
┌──────────────────────────────────────────────────┐
│ OBSERVABILITY STACK │
│ OTel Collector ──► Jaeger (distributed traces) │
│ Prometheus ──────────────► Grafana │
└──────────────────────────────────────────────────┘
Key design principle: Graceful degradation + Human-in-the-Loop (HITL). The Agent Builder agent halts safely and hands control back to the operator when it cannot reach a decision with sufficient confidence — it never guesses on critical infrastructure.
All three services are deployed and running on Google Cloud Run:
Run a live attack against production:
.\attack.production.ps1 status # verify all services healthy
.\attack.production.ps1 ddos # DDoS — Gemini blocks IPs + rate limit
.\attack.production.ps1 sql # SQL Injection — Gemini activates WAF
.\attack.production.ps1 brute # Brute Force — Gemini blocks source IPs
.\attack.production.ps1 stop # reset defenses
The attacker container runs locally and targets the Cloud Run victim-service over HTTPS. Watch the Command Center dashboard for the full detection → reasoning → neutralization cycle in real time.
Google Cloud Agent Builder (Vertex AI ReasoningEngine) is the central orchestrator of SentinelMCP. The implementation lives in sentinel_mcp/agent/agent_builder.py.
SentinelAgent inherits from vertexai.preview.reasoning_engines.Queryable — the official Agent Builder programmatic interface — and can run locally or be deployed to the managed Agent Builder service with a single command.
Key code — sentinel_mcp/agent/agent_builder.py:
class SentinelAgent(reasoning_engines.Queryable):
def set_up(self):
# MCP tools as Vertex AI FunctionDeclarations — Gemini selects at runtime
mcp_tools = Tool(function_declarations=[
FunctionDeclaration(name="block_ip_address", ...),
FunctionDeclaration(name="activate_waf", ...),
FunctionDeclaration(name="rate_limit_requests", ...),
FunctionDeclaration(name="scale_service", ...),
FunctionDeclaration(name="collect_forensic_logs", ...),
FunctionDeclaration(name="analyze_attack_pattern", ...),
])
self._model = GenerativeModel("gemini-2.0-flash-001", tools=[mcp_tools])
self._chat = self._model.start_chat()
def query(self, *, incident: dict) -> dict:
# Entry point — Agent Builder calls this for every Dynatrace webhook
response = self._chat.send_message(threat_prompt(incident))
tool_calls = [{"name": p.function_call.name, "args": dict(p.function_call.args)}
for p in response.candidates[0].content.parts if p.function_call]
return {"engine": "agent_builder", "tool_calls": tool_calls, ...}
Deploy to Google Cloud Agent Builder:
# Test locally (no GCP needed with google_ai_studio backend)
python scripts/deploy_agent_builder.py --test-only
# Deploy to managed Agent Builder endpoint
python scripts/deploy_agent_builder.py --project my-gcp-project
Set Agent Builder as the active backend:
# .env
GEMINI_BACKEND=agent_builder
GOOGLE_CLOUD_PROJECT=my-gcp-project
VERTEX_LOCATION=us-central1
SentinelMCP integrates Dynatrace observability at three layers:
OpenTelemetry pipeline — The sentinel-otel-collector ingests spans and metrics from the FastAPI core and forwards them to the Dynatrace Mock endpoint (OTLP/HTTP :14318). Every incident, tool execution, and LLM call is traced end-to-end with full correlation IDs.
Anomaly Engine with auto-trigger — dynatrace-mock runs a background loop that monitors http_requests_total, computes a Threat Risk Score (dynatrace_mock_sentinel_risk_score, 0–10), and fires POST /api/v1/alerts/simulate/{type} to SentinelMCP automatically when the score crosses the critical threshold — replicating the exact behavior of a production Dynatrace Davis anomaly detection webhook.
Grafana dashboard fed by Dynatrace metrics — The Risk Score gauge and timeline consume dynatrace_mock_sentinel_risk_score directly, making it possible to visualize the precise moment Dynatrace flagged the anomaly versus the moment SentinelMCP achieved neutralization.
The Gemini agent discovers its defense capabilities dynamically at runtime — no hardcoded tool lists, no prompt rewriting when capabilities change:
GET /mcp/tools → returns 11 tool descriptors → Gemini selects and invokes tools
Each tool is labeled REAL or Audit-Only in the live catalog. Gemini reads this flag, understands what it can actually do on live infrastructure, and justifies every tool selection in its reasoning trace. Adding a new defense capability requires zero prompt engineering.
Tools that act on live infrastructure:
Requirements: Docker Desktop 24+, Google Cloud credentials or AI Studio API key, ~3 GB disk, ~2 GB RAM.
docker compose up -d --build
First run downloads base images (~3 GB, 5–10 min). Subsequent runs take under 1 minute.
cd simulacion
docker compose up -d victim-service
cd ..
docker compose ps
# Expected: 8 services running/healthy
curl http://localhost:8000/health
# Expected: {"status": "healthy", "service": "SentinelMCP", ...}
.\attack.ps1 ddos # DDoS attack (default)
.\attack.ps1 sql # SQL Injection
.\attack.ps1 brute # Brute Force
.\attack.ps1 stop # Stop attack + reset defenses
.\attack.ps1 status # Check system state
Open the Command Center while the attack runs:
http://localhost:8000/dashboard
Watch the 4 phases in ~25 seconds:
THREAT DETECTED — Dynatrace fires the alertDEFENDING — Gemini reads the MCP tool catalog, selects actions, logs reasoningNEUTRALIZED — MTTD and MTTR displayed with full audit trailSentinelMCP is built on Gemini. Choose the authentication method that fits your environment:
Option A — Google AI Studio (fastest setup):
# Edit .env
GOOGLE_API_KEY=AIza...your_key_here
GEMINI_BACKEND=google_ai_studio
Option B — Vertex AI on Google Cloud:
gcloud auth application-default login
.\scripts\setup_gcloud.ps1 # sets project, creates SA key, updates .env automatically
Then restart the AI engine: docker compose restart api
GET http://localhost:8001/mcp/tools
SentinelMCP employs a Fail-Safe Audit Mode. If target infrastructure is unreachable, the agent records intended actions without breaking the pipeline, ensuring graceful degradation. Gemini reads the REAL / Audit-Only flag in the catalog — it knows precisely what it can execute versus what it can only recommend.
sentinel_mcp/
├── api/ FastAPI core — routes, schemas, dashboard UI
├── agent/ Decision engine + LLM providers (Gemini 2.0 Flash, Vertex AI)
├── mcp_server/ MCP server + 11 tool implementations
├── services/ Incident service, remediation orchestrator, threat calculator
├── observability/ OTel / Dynatrace / SigNoz providers
└── core/ Config, logging, exceptions
simulacion/
├── victim-service/ FastAPI target service with /admin/* control plane
└── attacker/ Python attack engine (DDoS / SQLi / brute force)
docker/
├── prometheus.yml Scrape config (victim-service at 5s interval)
└── grafana/ Auto-provisioned dashboard — 6-panel infrastructure witness
| Service | URL |
|---|
| Command Center (Dashboard) | https://sentinel-api-62d3d66zda-uc.a.run.app/dashboard |
| Swagger API Docs | https://sentinel-api-62d3d66zda-uc.a.run.app/docs |
| Health Check | https://sentinel-api-62d3d66zda-uc.a.run.app/health |
| MCP Tool Catalog | https://sentinel-mcp-62d3d66zda-uc.a.run.app/mcp/tools |
| Victim Service | https://victim-service-62d3d66zda-uc.a.run.app |
| Responsibility | Implementation |
|---|
| Webhook intake | SentinelAgent.query(incident=...) — called by Agent Builder on every Dynatrace alert |
| Tool declarations | 6 MCP tools registered as Vertex AI FunctionDeclaration objects in set_up() |
| Reasoning | Gemini 2.0 Flash reads threat context + tool catalog, selects the minimum tools, auto-invokes them |
| HITL gate | If Gemini returns no tool calls (confidence < threshold), escalate_to_humans=True is emitted |
| Audit | Every tool call logged in MongoDB Atlas + exported as OTel span to Jaeger |
| Tool | What it does |
|---|
block_ip_address | POST /admin/block_ip — blocks attacker IPs in the running middleware |
activate_waf | POST /admin/waf — enables WAF blocking mode in the running service |
rate_limit_requests | POST /admin/rate_limit — sliding-window rate limiter, active immediately |
scale_service | Docker SDK over socket — starts real replica containers under load |
rollback | POST /admin/reset_defenses — demonstrates full incident lifecycle: attack → defend → restore |
collect_forensic_logs | Captures real evidence from running containers for post-incident review |
build_attack_timeline | Chronological timeline from live container logs |
analyze_attack_pattern | Classifies attack type with real incident context data |
identify_iocs | Extracts real IPs, user-agents, and payloads from live incident files |
| URL | What it shows |
|---|
| https://sentinel-api-62d3d66zda-uc.a.run.app/dashboard | Command Center — main demo UI |
| https://sentinel-api-62d3d66zda-uc.a.run.app/docs | Swagger — interactive API explorer |
| https://sentinel-api-62d3d66zda-uc.a.run.app/health | Health check |
| https://sentinel-api-62d3d66zda-uc.a.run.app/api/v1/incidents | Incident history (JSON) |
| https://sentinel-mcp-62d3d66zda-uc.a.run.app/mcp/tools | Live MCP tool catalog as read by Gemini |
| https://victim-service-62d3d66zda-uc.a.run.app | Victim service (the target under attack) |
| URL | What it shows |
|---|
http://localhost:8000/dashboard | Command Center — main demo UI |
http://localhost:8000/docs | Swagger — interactive API explorer |
http://localhost:8000/api/v1/incidents | Incident history (JSON) |
http://localhost:8000/api/v1/incidents/statistics/summary | MTTD / MTTR averages across all incidents |
http://localhost:8001/mcp/tools | Live MCP tool catalog as read by Gemini |
http://localhost:8080 | Victim service (the target under attack) |
http://localhost:14499 | Dynatrace Mock — live metrics + anomaly engine |
http://localhost:16686 | Jaeger — distributed traces |
http://localhost:9090 | Prometheus — raw metrics |
http://localhost:3000 | Grafana — infrastructure dashboard (admin / admin) |
| Scenario | Script | What happens |
|---|
| DDoS | .\attack.ps1 ddos | 1000 req/s flood; Gemini blocks IPs + enables rate limit |
| SQL Injection | .\attack.ps1 sql | Payload detection; Gemini activates WAF in blocking mode |
| Brute Force | .\attack.ps1 brute | Login hammering; Gemini blocks source IPs + enables WAF |
| Auto-mode | Dashboard 🎯 Auto ON | Random attacks every 45–90s, fully autonomous response |
| Tool | Category | Mode |
|---|
analyze_attack_pattern | analysis | REAL |
identify_iocs | analysis | REAL |
block_ip_address | defense | REAL → victim-service |
activate_waf | defense | REAL → victim-service |
rate_limit_requests | defense | REAL → victim-service |
scale_service | defense | REAL → Docker SDK |
collect_forensic_logs | forensic | REAL |
build_attack_timeline | forensic | REAL |
patch_vulnerabilities | remediation | Audit-Only |
apply_hardening | remediation | Audit-Only |
rollback | remediation | REAL → victim-service |
| Layer | Technology |
|---|
| Agent Orchestrator | Google Cloud Agent Builder (Vertex AI Agent) |
| LLM | Gemini 2.0 Flash — via google-genai SDK |
| Tool protocol | MCP (Model Context Protocol) — 11 real tools |
| API | FastAPI + Uvicorn (Python 3.11) |
| Database | MongoDB 7.0 Atlas (Motor async) |
| Observability | OpenTelemetry → Dynatrace |
| Tracing | Jaeger |
| Metrics | Prometheus + Grafana |
| HTTP client | httpx (async) |
| Container orchestration | Docker Compose v2 |