
AI Incident Assistant
Production-style incident response playground: authenticated chat, MCP incident tools, template-driven CAN/RCA generation, Supabase sessions + quotas, and gateway-routed model orchestration.
What it is
AI Incident Assistant is a production-style incident response playground. Operators sign in, chat with an LLM, create/update Sev1 incidents, load templates (CAN, Sev1 canvas, RCA), and generate document outputs from structured incident data.
The build demonstrates gateway-routed models, MCP-backed tools, Supabase-backed auth/sessions, rolling per-user chat quotas, and hybrid observability (gateway-level metrics plus trace-level tooling).
Capability Matrix
| Area | Behavior |
|---|---|
| Chat Orchestration | Route handler manages model selection, tool binding, token trimming, and persistent session synchronization. |
| Authentication | Supabase Auth + middleware edge guards, fronted by Cloudflare Turnstile protection. |
| Session Memory | Postgres JSONB envelope stores raw messages alongside a structured memory summary and key facts, re-injected on every turn. |
| Abuse Controls | Rolling per-user window via Supabase RPC directly enforced on the chat API. |
MCP Tool Surface
- create_incident
- get_incident
- update_incident
- list_incidents
- get_can_templates
- get_sev1_canvas
- get_rca_templates
- load_template
- generate_can_document
- generate_rca_document
- list_tools
Incident/template storage is local JSON in the MCP server data directory with validation, safer writes, and bounded runtime.
Architecture & Flow
A high-fidelity breakdown of how the AI Incident Assistant orchestrates UI, model generation, and tool execution.
01 / Pipeline
Optimized Request Pipeline
Thin system prompt, LangChain-trimmed history, persisted session memory folded into the system string, then branch into model-only or tool-enabled execution.
02 / Retention
Context Retention Flow
From the browser through load/merge of the envelope, optional CAN guardrails, token trimming, and generation, with memory written back under the same row the user already owns via RLS.
03 / Execution
End-to-End Runtime
Request execution from user submit through API orchestration, decision gates, optional MCP calls, and response delivery.
Environment Controls
AI_GATEWAY_MODEL, AI_GATEWAY_BASE_URLNEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEYCHAT_QUOTA_MAX, CHAT_QUOTA_WINDOW_HOURSTURNSTILE_SECRET_KEY, CAPTCHA_COOKIE_SECRETSyed Ibtihaj
Design & Code by Syed Ibtihaj
Actively maintaining this site and pushing new work to GitHub as it ships.
© 2026. Built with Next.js 16