Repository navigation
Description
Rewritten on 2026-11-21 to fit the project plan: the product is fully operable by AI agents through MCP (north star P8, D14, D15) and the backend is written in Effect (D16). The previous version is in this issue's edit history.
Problem
Agents need authenticated, bounded access to everything the owner can see, without a session cookie.
Scope
- Extend the existing API keys with scopes
read,write,delete, andadmin(D15), plus an optional restriction to specific telemetry projects. Keep shown-once hashed secrets, expiry, disable, and revoke. Existing keys (Prometheus metrics keys until SCOPE-001, SCOPE-001: Remove all public-facing features (status pages, public incidents, badges, Prometheus) #192, removed that endpoint) get no scopes, so nothing is promoted silently; the owner re-scopes them explicitly. - Introduce typed, transport-free query services for monitors (list and current status, bounded history and uptime, important events, certificate and domain expiry). Socket handlers and MCP tools both call them (D14). Move at least the monitor-list socket handler onto them to prove there is one owner.
- Every query has bounded page size, time range, and response bytes, with stable cursors and typed errors. DTOs gain freshness fields when feat: expose observation freshness and measured uptime coverage #78 lands (additive).
Acceptance criteria
- Scope tests: a
readkey cannot mutate anything; an unscoped legacy key can do nothing; revoked, disabled, and expired keys fail consistently. - Pagination is deterministic across equal timestamps and bounded against abusive input.
- Credential admission reuses the existing bounded auth and trusted-proxy policies.
Cut from the original issue
The general REST read API (MCP is the machine interface, D14), and the hard dependencies on #77, #78, and #82. Their fields join the DTOs when they land.
Constraints
Keep Bun, Vue, one compiled executable and SQLite (kuma.db), with the supported Kuma importer. No required hosted service, extra database, worker deployment, Node/npm fallback or new distribution path. Backend code is written in Effect (north star D16, house style in docs/effect.md): dependencies are Effect services provided through layers, expected failures are tagged errors, and every input is decoded with Schema. Use direct @/ imports; no new barrel, ad-hoc registry, broad any facade or @ts-nocheck. Code passes the TS 7 strict typecheck and the @cloudflare/oxlint-config lint (D17). Make additive schema changes through the existing upgrade path; keep legacy rows meaningful.
Implement the idea independently. Staygreen is a design reference at the pinned revision, licensed FSL-1.1-MIT; do not transplant its source, CSS, illustrations or branding into this MIT project.
Source starting points
- iglo:
src/server/auth.ts - iglo:
src/server/model/api_key.ts - iglo:
src/server/socket-handlers/api-key-socket-handler.ts - iglo:
src/server/bun-http-server.ts - Staygreen reference:
src/lib/agent-contract.ts - Staygreen reference:
src/lib/agent-service.ts - Staygreen reference:
src/lib/agent-auth.ts
Plan placement
Reconciled on 2026-11-21 with the project plan (docs/roadmap.md) and the fixed decisions (docs/north-star.md). If this issue and those documents still disagree, raise it instead of choosing.
- Stage: 1 — Agent track. This is the foundation every later MCP tool builds on.
- Depends on: refactor: extract remaining socket event families #68 (and refactor: replace RedBean with explicit SQLite models #67 if it lands first). Freshness fields from feat: expose observation freshness and measured uptime coverage #78 and evidence fields from feat: centralize safe monitoring evidence and secret redaction #77 and feat: link monitor outages to evidence and incident timelines #82 join the results additively when those land.
- Foundation first: starts after the Stage F exit gate (Stage F exit gate: foundation complete #120) closes, meaning types, guardrails, and the Effect rewrite are done. Build on the Effect services that own each responsibility after Stage F. File and module names in this issue describe the code as of 2026-10-28 and may have moved.
- Agent parity (P8): every capability this issue adds to the UI ships with its MCP tool in the same PR or stack, calling the same Effect service (D14). Writes follow the feat: command layer with idempotent, scoped, previewable writes #84 conventions (
request_id,dry_run, scopes). - GitHub dependencies: the blockers are also set as GitHub issue dependencies (see the issue sidebar).
Activity
[-]feat: add a bounded read-only monitoring API with scoped keys[/-][+]feat: scoped machine keys and transport-free query services[/+]