How to use MCP and the Insights Product.
Reference · v1 · Insights Product
Chapter 1
The context-mode OSS plugin already ships events from every coding session — tool calls, errors, prompts, file edits. The context-mode Platform ingests those events server-side and exposes the Insights Product through three lenses: a Dashboard, a REST API, and a Remote MCP server.
Three personas, three scope ceilings. Owner sees the whole org. Manager sees the teams they are authorized for (one team for a Team Lead, several for an EM). Member sees themselves only. The same backing queries power every surface — your role decides what the queries return.
Insights are derived patterns, not raw events. The pattern engine reads the shared events table and produces findings: stuck-on-error loops, secret-exposure hits, drop in adoption, top performers, week-over-week deltas. No separate ingest pipelines per tool — one firehose feeds everything.
"Same data, different lens, three roles."
Chapter 2
Two steps. Install the OSS plugin, then point it at the Platform with a one-line install script.
npm install -g context-mode/plugin marketplace add mksglu/context-mode~/.context-mode/platform.json.The script writes a 2-field config. That is the entire client surface per ADR-0006.
From this point the Forwarder hook (shipped with the OSS plugin) POSTs every canonical event to POST /api/v1/events — a single firehose endpoint. No per-tool routing, no client-side classification. Fire-forget, 2s timeout, returns 201.
Chapter 3
Three roles. Each has a hard scope ceiling enforced server-side, both in the REST middleware and in the MCP schema layer (the LLM never sees options it cannot use).
| Role | Scope ceiling | Persona example | Display |
|---|---|---|---|
| owner | self + team + org | CTO, founder, billing owner | "Owner" |
| manager | self + team (managed_teams) | EM, Team Lead, Director, DevOps Lead | "Team Lead of Backend" (1 team) "Manager of A, B, C" (2-3) "Manager of N teams" (4+) |
| member | self only | IC developer | "Member" |
managed_teams is a JSON array on the member row. Owner edits it from the dashboard. A Team Lead has one entry; an EM has several. Handlers at scope=team filter SQL by managed_teams; Owner skips the filter; Member is forced to self-scope by schema (the scope enum simply lacks "team" and "org" for member tokens).
Single-team managers see their team plus an anonymized peer comparison. Multi-team managers get fan-out queries across all teams in their array.
Chapter 4
The Insights MCP server runs on Cloudflare Workers with the McpAgent Durable Object pattern (ADR-0005). Transport is Streamable HTTP — no local install, no stdio, no extra process. Point your client at the URL with your Machine Token in the header.
Seven agents supported across two tiers. The bearer token is inlined directly into each tool's per-user config file or mcp add command — same security model as ~/.ssh/id_rsa (mode 0600, user-scoped). Works the same on macOS, Linux, and Windows. No shell profile edits.
Tier 1 — CLI install: Claude Code, Gemini CLI, Qwen Code.
Tier 2 — Edit config file: Codex (~/.codex/config.toml), OpenCode (~/.config/opencode/opencode.json), Cursor (~/.cursor/mcp.json), Kimi Code (~/.kimi-code/mcp.json). Token sits in the headers / http_headers field of each agent's own config — file mode 0600, no env vars.
OpenCode and Kimi Code follow the same JSON shape under mcp / mcpServers. The Connect this machine wizard in the dashboard renders the exact command — already populated with your token — for whichever agent you pick.
On connect, the server inspects your token, resolves your role and managed_teams, and registers all 9 Insights tools with role-tuned scope enums (ADR-0007). A Member token sees only scope: "self" in tool schemas; a Manager sees "self" | "team"; an Owner sees "self" | "team" | "org". The schema is the first defense layer — the LLM cannot construct a scope outside the enum.
Chapter 5
Nine tools. Pick the one whose verb matches your intent. Every response includes scope_resolved.reason explaining which view the server returned and why.
24h | 7d | 30d | 90dChapter 6
Same data, raw access. Useful for custom dashboards, BI imports, or wiring Insights into your existing tooling. Every request takes Authorization: Bearer ctxm_* — the same Machine Token used by the Forwarder and MCP.
Ingest
events table. Zod discriminated union on event.type.
Query
compare_teams.
Org & members
managed_teams.
role and managed_teams.
Wire format: Authorization: Bearer ctxm_*, Content-Type: application/json, X-Schema-Version: 2.
Chapter 7
A quick tour of the web UI at platform.context-mode.com. Every tab is a different view onto the same backing queries.
Insights tab — the default landing surface. 177 patterns across 6 categories (adoption, effectiveness, efficiency, engagement, quality, security). Findings list ranks by impact score, scoped by your role.
Members tab — roster view. Owner sees everyone and can edit role + managed_teams inline. Manager sees their authorized teams. Member sees only themselves.
Settings — Org Teams list (used by managed_teams validation), Bootstrap Token generation, Machine Token rotation, billing.
Connect Machine modal — first-login UX. Generates a one-shot Bootstrap Token, shows the install script command, opens with a copy-to-clipboard CTA.
Chapter 8
A quick architecture reference. Full details live in the docs/adr/ directory of the repo.
Forwarder — an 80-line OSS module (hooks/platform-bridge.mjs) shipped with the plugin. Reads ~/.context-mode/platform.json on cold start and every 60s thereafter. POSTs canonical events to the firehose.
Single firehose — POST /api/v1/events is the entire ingest surface (ADR-0006). Products differ in interpretation, not transport. Insights, future Audit, future Risk Score events all flow through this one URL.
Validation — server-side Zod discriminated union on event.type (ADR-0004). The right variant validates the right payload; row lands in the 35-column events table tagged by type.
Insights engine — all 8 MCP tools route through src/insights/engine.ts::evaluatePatterns(). No tool defines its own SQL. The same in-process helpers back the REST endpoints — parity between dashboard, REST, and MCP is guaranteed by construction.
Remote MCP — Cloudflare Workers + McpAgent Durable Object (ADR-0005). Streamable HTTP transport. Per-session tool registration with role-tuned schemas (ADR-0007).
FAQ
"org" in the scope enum (ADR-0007). The LLM cannot even construct the call. The REST layer enforces the same ceiling via middleware.