Skip to content

feat(mcp): add scoped read-only agent access - #779

Merged
unjica merged 1 commit into
developfrom
codex/mcp-mvp
Oct 12, 2026
Merged

unjica merged 1 commit into
developfrom
codex/mcp-mvp

Conversation

@unjica

@unjica unjica commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Change

Coding agents can read selected Telemetry Tracker projects through one stateless
Streamable HTTP POST /mcp endpoint. Five tools expose minimized telemetry;
Settings → Agent access creates/revokes dedicated expiring tokens, and issue
details offer a server-sanitized Copy for agent action. Adds an additive migration
and setup examples for all seven requested clients.

Security and design

  • tt_read_<publicId>_<256-bit secret>; SHA-256 digest at rest, timing-safe
    verification, one-time disclosure, 90-day default / 365-day maximum expiry.
    Read tokens are rejected everywhere except /mcp; ingest keys and dashboard
    sessions cannot authenticate MCP. No OAuth or write tools.
  • One org, 1–25 explicitly selected projects, current project only by default.
    Every request intersects scope with active projects and creator's current org
    membership (TT grants project access through org membership). No auth cache.
  • Creation uses existing canCreateApiKey (OWNER/EDITOR integration permission);
    VIEWER cannot create. Creator may revoke their own token; OWNER may revoke any
    in the org. Create/revoke/observed-expiry audit and mutations commit together.
    Expiry audit is recorded once at first authenticated observation after expiry.
    Persistent last-used, total request count and last-tool fields contain no secrets.
  • All five tools declare readOnlyHint: true. Output uses explicit fields, counts
    rather than identities, no context/properties/source maps, read-time scrubbing,
    query removal, labelled untrusted strings, truncation and control/invisible
    character stripping. API/dashboard Sentry filters also redact read tokens.
  • Requests ≤16 KiB, tool results ≤32 KiB, lists default to 24h and small page sizes.
    DB-backed atomic token/org minute buckets are shared across replicas: Free
    30/120, paid 120/600. Browser-origin requests are refused.
  • Off unless TELEMETRY_MCP_ENABLED=true; also refused when ingest scrubbing is
    disabled. Migration must be applied before enablement.

Proxy finding / release gate

Fastify has no trustProxy configuration and existing Fastify rate-limit scopes
use the default IP key. If Railway exposes a proxy source IP, existing clients may
share buckets. This is supported by code, not verified against production traffic.
MCP quotas are independent of IP. Unconditional proxy trust is unsafe without the
trusted-hop boundary, so existing behavior is documented for operator follow-up.
Do not release until this concern is resolved and database CI passes.

No merge, deploy, release PR or production access occurred. Runner publishes this
feature PR only. origin/develop and the starting HEAD are 4dc79e9; local
develop is stale. origin/main and origin/develop have identical trees; the
only develop-only commit is reviewed sync PR #777. Refresh that assessment before
any eventual release.

Validation

  • pnpm lint: pass, zero warnings.
  • pnpm test: 1,551 passed; 163 DB integration tests skipped (includes 17 new MCP
    DB tests). API 1,103; dashboard 300; core 67; Vite 14; Node 27; Next 15; React
    Native 8; publishing guards 17. No test failures.
  • Running-endpoint MCP SDK test with mocked database: initialize OK; tools/list
    contains 5 read-only tools; each tool OK; privacy, scope and write denial OK.
    Also adds a real-DB running-endpoint SDK test for CI.
  • pnpm build: pass across all workspaces (includes production TS validation).
    tsc --noEmit -p apps/api/tsconfig.build.json: pass.
  • Full API tsc --noEmit -p tsconfig.json: 106 existing diagnostics in unchanged
    test files. Dashboard tsc --noEmit: 6 existing diagnostics in unchanged
    google-analytics/marketing-seo-head tests. No diagnostics in new MCP/UI files.
    Tests and type settings were not weakened.
  • Prisma generate and schema validate: pass. Migration execution and real-DB
    tests are pending outside sandbox: local initdb failed with shmget: Operation not permitted. CI already runs migrations and DB integration tests.
  • git diff --check: pass; reviewed both tracked diff and new files. Incidental
    generated version / React Native dist changes from build were restored.
  • CI/PR URL pending runner publication; no CI success is claimed.

Legal review needed

TODO(legal) in setup docs and deployment docs: review customer-selected AI export
wording and any required privacy-policy/DPA changes. Neutral wording only; no
claim of existing policy/DPA coverage or EU-only processing. /privacy unchanged.

Follow-ups / limits

Verify Railway proxy trust and existing IP limiter behavior before release. Run
all DB integration tests and the migration on the CI database; wait for required
CI checks. Legal review remains pending. Offset pagination is bounded to 10,000
and may shift during ingest. Pattern-based scrubbing cannot guarantee removal of
all identifying free text; no arbitrary context is returned. Expiry audit is lazy;
usage is cumulative rather than a per-day ledger. Hard-deleted token/org bucket
rows can be cleaned by an operator. Zed docs do not establish env expansion in
remote headers: its env-only example uses the third-party mcp-remote bridge;
review/pin it under dependency policy, or use an external agent's native config.

Add a stateless Streamable HTTP endpoint with dedicated hashed read tokens,
explicit project scopes, live membership checks, transactional lifecycle audit
and shared per-token/organization rate limits. Keep MCP off by default and
refuse access when ingest scrubbing is disabled.

Expose five privacy-minimized read tools, token settings, Copy for agent,
client setup docs and protocol, security, UI and database integration tests.
@unjica
unjica merged commit 56ecf33 into develop Oct 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant