# Domain — platform-service (MCP + A2A Opportunities)

## Why this domain is ideal for MCP

`platform-service` is already organized as a set of well-defined modules and stable REST endpoints (Fastify 5 + Zod), with:

- telemetry ingestion + query + policies
- remote diagnostics sessions
- jobs, delivery, sessions, maintenance
- settings, flags, rate limits
- webhooks subscriptions

This makes it a near-perfect backing store for MCP tools.

## High-value MCP tool proposals

### Telemetry

- `telemetry.queryEvents(filters)`
- `telemetry.listClusters(filters)`
- `telemetry.updateClusterStatus(clusterId, pk, status)`
- `telemetry.listPolicies()`
- `telemetry.previewPolicy(targeting)`
- `telemetry.createPolicy(input)`
- `telemetry.updatePolicy(id, updates)`
- `telemetry.deletePolicy(id)`
- `telemetry.getMetrics()`
- `telemetry.getGeoDistribution(from?, to?)`

**A2A use**

- Telemetry Analyst Agent automates:
  - time window selection
  - cluster-to-user drilldown
  - policy suggestions (targeting + expiry)

### Remote diagnostics

- `diagnostics.createSession(input)`
- `diagnostics.listSessions(filters)`
- `diagnostics.getSession(id)`
- `diagnostics.updateSession(id, updates)`
- `diagnostics.cancelSession(id)`
- `diagnostics.getLogs(sessionId, filters)`
- `diagnostics.getTraces(sessionId, filters)`
- `diagnostics.listScreenshots(sessionId)`

**Target identifiers (schema-aligned):** `targetUserId`, `targetAnonymousId`, `targetDeviceId`.

**A2A use**

- Diagnostics Orchestrator Agent monitors session lifecycle and compiles summaries.

### Jobs

Current module provides list/update/trigger/list runs.

- `jobs.list()`
- `jobs.get(id)`
- `jobs.update(id, updates)`
- `jobs.trigger(jobName)`
- `jobs.listRuns(jobName, limit)`

**Note**

- Current `jobs/routes.ts` uses `DEFAULT_PRODUCT_ID = 'lysnrai'`. For MCP, prefer explicit productId routing.

### Settings / kill switch

- `settings.get(userId)`
- `settings.update(userId, patch)`
- `settings.getDeviceResolved(userId, deviceId)`
- `settings.setDeviceOverrides(userId, deviceId, overrides)`
- `settings.clearDeviceOverrides(userId, deviceId)`
- `settings.checkKillSwitch(productId)`

### Flags

- `flags.list(productId)`
- `flags.get(key, productId)`
- `flags.upsert(key, enabled, targeting, description)`

### Maintenance

- `maintenance.getCurrent(productId)`
- `maintenance.set(productId, mode, bypassRules, windows)`

### Webhooks

- `webhooks.listSubscriptions(productId)`
- `webhooks.createSubscription(input)`
- `webhooks.updateSubscription(id, productId, updates)`
- `webhooks.deleteSubscription(id, productId)`
- `webhooks.listDeliveries(subscriptionId, limit)`
- `webhooks.test(subscriptionId)`
- `webhooks.rotateSecret(subscriptionId)`

## Recommended MCP resources

- `platform-service.modules`
  - enumerates module names, key endpoints, auth requirements
- `telemetry.eventSchema`
- `diagnostics.sessionSchema`

## Recommended A2A workflows backed by platform-service

### 1) Support debug pack

- input: user report
- output: timeline + clusters + recommended actions + (optional) diagnostics session results

### 2) Canary rollout of additional telemetry

- build policy → preview → create with expiry → monitor cluster changes

### 3) Post-incident cleanup

- resolve clusters
- remove policies
- export audit log for the incident window
