Commit de41225
feat(customermcp): Phase 3 — Infrastructure Context Resources and Inventory Tools (#4597)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Summary
Implements Phase 3 of the Customer-Facing MCP Server. This phase adds
infrastructure context — sources and snapshots — enabling AI agents to
understand what infrastructure is connected, what resource types are
discoverable, and what snapshots exist.
## What changed
### New Tools (4)
| Tool | Scope | Description |
| --- | --- | --- |
| `list_sources` | `sources:read` | List all connected sources with
optional `status` and `type` filters |
| `get_source_status` | `sources:read` | Get detailed status for a
specific source by UUID |
| `list_snapshots` | `changes:read` | List all infrastructure snapshots
with summary counts |
| `get_snapshot` | `changes:read` | Get snapshot details; summary by
default, full items with `include_items=true` |
### New Resources (2)
| Resource | Scope | Description |
| --- | --- | --- |
| `sources://list` | `sources:read` | Static list of all connected
sources |
| `sources://{source_id}/types` | `sources:read` | Resource template:
available types for a specific source |
### Architecture patterns established
1. **MCP ResourceTemplate** — First use of `server.AddResourceTemplate`
with RFC 6570 URI templates and scope-enforced `addResourceTemplate`
wrapper
2. **Cross-service gateway calls** — `SnapshotsServiceClient` created
once at startup with `ContextAwareAuthTransport` for per-request JWT
passthrough to the gateway
3. **sdp-go interface reuse** — `ManagementServiceHandler` and
`SnapshotsServiceClient` used directly as deps (no custom interfaces),
following the updated convention from the plan
### Files changed
| File | Change |
| --- | --- |
| `go/auth/auth_client.go` | Add `ContextAwareAuthTransport` and
`NewContextAwareAuthClient` for per-request JWT extraction |
| `go/auth/context_aware_auth_test.go` | Unit tests for the new
transport |
| `services/api-server/customermcp/deps.go` | Add `SourcesService` and
`SnapshotsService` fields to `Deps` |
| `services/api-server/customermcp/sources.go` | `list_sources` and
`get_source_status` tool handlers |
| `services/api-server/customermcp/snapshots.go` | `list_snapshots` and
`get_snapshot` tool handlers |
| `services/api-server/customermcp/resources.go` | `sources://list`
resource and `sources://{source_id}/types` template |
| `services/api-server/customermcp/scope.go` | `addResourceTemplate`
scope wrapper |
| `services/api-server/customermcp/tools.go` | Register all 4 new tools
|
| `services/api-server/customermcp/format.go` | `formatSourceStatus` and
`formatSourceManaged` helpers |
| `services/api-server/customermcp/sources_test.go` | Comprehensive
tests for source tools and resources |
| `services/api-server/customermcp/snapshots_test.go` | Comprehensive
tests for snapshot tools |
| `services/api-server/customermcp/changes_test.go` | Update test deps
for new tool registration |
| `services/api-server/customermcp/mcp_test.go` | Update test deps for
new tool registration |
| `services/api-server/service/main.go` | Add `ManagementService()`
accessor |
| `services/api-server/cmd/start.go` | Wire `SourcesService` and
`SnapshotsService` after Init() |
## Testing
- 43 new tests covering all tool handlers, resource handlers, scope
enforcement, format helpers, registration, error handling, and the
context-aware auth transport
- All existing Phase 1/2 tests continue to pass (40+ tests)
- Full compilation verified across `api-server`, `auth`, and
`customermcp` packages
<!-- CURSOR_AGENT_PR_BODY_END -->
Linear Issue:
[ENG-3579](https://linear.app/overmind/issue/ENG-3579/phase-3-customer-mcp-infrastructure-context-resources-and-inventory)
<div><a
href="https://cursor.com/agents/bc-56e4e223-5d42-425f-8aab-4f88772ddd27"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a
href="https://cursor.com/background-agent?bcId=bc-56e4e223-5d42-425f-8aab-4f88772ddd27"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
GitOrigin-RevId: 47728085e9b6275fd49ce451ff683e2e3a8f1c6b1 parent 0815f54 commit de41225
2 files changed
Lines changed: 117 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
55 | 91 | | |
56 | 92 | | |
57 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
0 commit comments