AgentRed is a small agent-scanning demo: a FastAPI backend that runs agent scans and streams events, and a Next.js frontend for running and visualizing scans.
This README documents requirements, how the project is structured, how to run it locally, the API surface, and development tips.
- Backend: Python + FastAPI. Exposes endpoints to start scans, stream events (SSE), and fetch final reports.
- Frontend: Next.js (React) app that starts scans and consumes the SSE stream to show progress and results.
- Purpose: demonstrate an automated agent scanner with event streaming and an interactive UI.
backend/— FastAPI app. Key modules:main.py— FastAPI app and routesevents.py— per-scan async event busorchestrator.py— scan orchestration and adaptive follow-upsscoring.py— trust score calculation and gradetools/— helpers (card fetcher, static rules, a2a client, etc.)
frontend/— Next.js app (app router). UI components incomponents/, API helpers inlib/.
- Python 3.11+
- Node.js 18+ (or the version supported by your package lock)
pipand a virtual environment toolnpmorpnpmfor the frontend
Optional:
gh(GitHub CLI) if you want to create fork/PR from the command line
Recommended: run from the repository root so backend is importable as a package.
- Clone the repo
git clone https://github.com/<OWNER>/AgentRed.git
cd AgentRed- Backend setup (Windows / PowerShell)
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
# From the repo root (important):
uvicorn backend.main:app --reload --port 8000- Frontend setup
cd frontend
npm install
npm run dev
# Open http://localhost:3000Notes:
- The backend run command must be executed from the repo root (so
backendis importable). If you run from insidebackend/, useuvicorn main:appinstead.
- Backend (
backend/config.pyreads these):DATABASE_URL— optional DB connection (if using storage features)CLICKHOUSE_URL,DATADOG_API_KEY— optional integrationsAGENT_CARD_PATH— override card fetch path
- Frontend:
NEXT_PUBLIC_API_BASE_URL— base URL of the backend (defaulthttp://localhost:8000)
Create a .env or set these in your environment for non-default behavior.
GET /health— health check. Returns{ ok: true }when healthy.POST /scan— start a scan. Body:{ "target_url": "https://example.com" }. Returns{ scan_id, stream_url }.GET /scan/mock— start a canned mock scan for UI development. Returns same shape asPOST /scan.GET /stream/{scan_id}— Server-Sent Events stream for scan progress (SSE). Events includescan_started,phase,finding,test_generated,test_running,adaptive_followup,report, anderror.GET /report/{scan_id}— final JSON report for a finished scan.
Example: start a mock scan and follow the stream (PowerShell)
$res = curl http://localhost:8000/scan/mock | ConvertFrom-Json
curl http://localhost:8000$($res.stream_url)Example: start a real scan (POST)
curl -X POST http://localhost:8000/scan -H 'Content-Type: application/json' -d '{"target_url":"http://example.com"}'The scoring.py module computes a trust score and a grade. A simple representation of a typical test-based score is:
Inline formula (example):
Grades are derived from ranges of the trust score (A/B/C etc.). See backend/scoring.py for the exact production formula.
To run the demo honeypot and scan it locally (two terminals):
# terminal 1
uvicorn honeypot.main:app --reload --port 8001
# terminal 2 (from repo root)
uvicorn backend.main:app --reload --port 8000
# then POST a scan to the backend pointing at the honeypot
curl -Method POST http://localhost:8000/scan -ContentType application/json -Body '{"target_url":"http://localhost:8001"}'- UI: the frontend expects the backend at
NEXT_PUBLIC_API_BASE_URL— set it in.env.localto test remote backends. - When encountering import errors with Uvicorn, ensure you run it from the repo root as shown above so
backendis onPYTHONPATH. - The frontend uses SSE (
EventSource) and expects thestream_urlreturned by/scanto be an absolute or leading-slash path.
- No formal test harness is included in this repo snapshot. For quick manual checks:
- Start backend, run
/scan/mock, confirm SSE events appear. - Start frontend dev server (
npm run dev) and exercise the UI.
- Start backend, run
- Fork the repo, work on a branch named like
fix/descriptionorfeat/description, push and open a PR againstmain. - Follow the existing code style. For frontend changes, run the dev server and verify UI behavior.
This repository is provided for demonstration purposes. Contact the repository owner for licensing and contribution guidance.