Skip to content

Commit 60f02bc

Browse files
thomas-manginclaude
andcommitted
chore(mcp): close spec-mcp-5-apps and spec-mcp-0-umbrella, write learned summaries
All five MCP modernization phases complete: streamable HTTP, OAuth, elicitation, tasks, and apps. Replace specs with learned summaries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ff8717c commit 60f02bc

4 files changed

Lines changed: 140 additions & 1027 deletions

File tree

plan/learned/682-mcp-5-apps.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# 682 -- MCP 5 Apps (UI Resources)
2+
3+
## Context
4+
5+
MCP Apps (2026-01-26 extension) lets the server advertise UI resources
6+
alongside tools: tool descriptors carry `_meta.ui.resourceUri` pointing
7+
to embedded HTML/CSS/JS assets served via `resources/list` and
8+
`resources/read`. Clients render the HTML in a sandboxed iframe; the
9+
server is purely a static asset server. This was Phase 5 of the MCP
10+
modernization umbrella (spec-mcp-0-umbrella).
11+
12+
## Decisions
13+
14+
- **Embedded FS only.** UI bundles ship via `//go:embed` in
15+
`internal/component/mcp/ui/embed.go`. No on-disk loading path.
16+
Single-binary deployment model; operators get new UI by deploying a
17+
new daemon.
18+
19+
- **Capability gate on read, not on advertisement.** `_meta.ui.*` is
20+
emitted in `tools/list` unconditionally so clients discover UI-capable
21+
tools without a round-trip. `resources/list` and `resources/read` are
22+
gated on `capabilities.resources = {}` declared at initialize.
23+
24+
- **MIME sniffing is extension-based, not content-based.** Predictable,
25+
fast, no dependency on `http.DetectContentType`. Unknown extensions
26+
default to `application/octet-stream`.
27+
28+
- **YANG extensions for UI metadata.** `ze:ui-resource` (path),
29+
`ze:ui-permissions` (capabilities), `ze:ui-csp` (Content-Security-Policy)
30+
on command-tree grouping containers. Follows the same
31+
extension-on-container pattern as `ze:task-support`. `PathToUIResource`
32+
walks -cmd modules; hub wiring propagates to `CommandInfo.UIResource`;
33+
`buildToolDef` emits `_meta.ui` when non-nil.
34+
35+
- **First UI bundle: bgp-peer.** Peer status panel with state, ASN, and
36+
name. Uses safe DOM methods (no innerHTML). Tagged on the `peer`
37+
container in `ze-peer-cmd.yang`.
38+
39+
## What Worked
40+
41+
- The `ze:task-support` extension pattern (YANG -> command.go walker ->
42+
hub map -> CommandInfo field -> buildToolDef emission) transferred
43+
directly to UI resources. Three new YANG extensions, one new walker,
44+
one new field, one enrichment block.
45+
46+
- Path-traversal prevention is simple with `path.Clean` + prefix check
47+
before any `fs.ReadFile`. The embedded FS adds a second layer
48+
(rejects `..` outside its root).
49+
50+
- The `groupUIResource` function inherits the UI annotation from any
51+
action in the group, so tagging the parent container (not individual
52+
commands) works correctly with the existing grouping logic.
53+
54+
## What to Watch
55+
56+
- `resources/updated` notifications are deferred. UI bundles are
57+
immutable at runtime so there is no notification trigger today.
58+
59+
- `resources/list` pagination is not implemented. The embedded FS is
60+
small enough that the full list fits comfortably in one response.
61+
62+
- The `lookupUIResource` function in hub walks parent paths to find the
63+
annotation. If a deeply nested command should NOT inherit the UI
64+
resource from its parent, an override mechanism would be needed.
65+
66+
## Files
67+
68+
| File | Change |
69+
|------|--------|
70+
| `internal/component/mcp/resources.go` | New: MIME sniffer, URI validator, `listResources`, `readResource`, `resourcesList`/`resourcesRead` Streamable methods |
71+
| `internal/component/mcp/resources_test.go` | New: 16 tests covering list, read, traversal, capability gate, binary blob |
72+
| `internal/component/mcp/ui/embed.go` | New: `//go:embed bgp-peer` exposing `embed.FS` |
73+
| `internal/component/mcp/ui/bgp-peer/` | New: `index.html`, `style.css`, `app.js`, `icon.png` |
74+
| `internal/component/mcp/session.go` | `clientResources` bit, `ClientSupportsResources()`, `CreateWithCapabilities` 5th arg |
75+
| `internal/component/mcp/streamable.go` | `resources/list`/`resources/read` dispatch, `parseResourcesCapability`, `resources: {}` in initialize |
76+
| `internal/component/mcp/tools.go` | `UIResourceInfo`, `uiResource` on action/toolGroup, `groupUIResource`, `_meta.ui` in `buildToolDef` |
77+
| `internal/component/mcp/tools_test.go` | 3 tests for `_meta.ui` enrichment |
78+
| `internal/component/config/yang/command.go` | `UIResourceInfo`, `PathToUIResource`, `getUIResourceExtensions` |
79+
| `internal/component/config/yang/modules/ze-extensions.yang` | `ze:ui-resource`, `ze:ui-permissions`, `ze:ui-csp` extensions |
80+
| `internal/component/bgp/plugins/cmd/peer/schema/ze-peer-cmd.yang` | Tagged `peer` container with UI extensions |
81+
| `cmd/ze/hub/main.go` | `uiResourceByPath` in `serverCommandLister`, `lookupUIResource` call |
82+
| `cmd/ze/hub/mcp.go` | `lookupUIResource` function |
83+
| `docs/architecture/mcp/overview.md` | Resources Capability section, files table, capability table, roadmap |
84+
| `docs/architecture/api/commands.md` | `resources/list`, `resources/read` method entries |
85+
| `docs/features.md` | MCP row updated with Apps |
86+
| `docs/comparison.md` | MCP Apps row added |
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# 683 -- MCP 0 Umbrella (Protocol Modernization)
2+
3+
## Context
4+
5+
The MCP umbrella (spec-mcp-0-umbrella) coordinated five phases of MCP
6+
protocol modernization. All five phases have landed:
7+
8+
| Phase | Spec | Learned | Delivers |
9+
|-------|------|---------|----------|
10+
| 1 | spec-mcp-1-streamable-http | 636 | Streamable HTTP transport, sessions, SSE, Origin validation |
11+
| 2 | spec-mcp-2-remote-oauth | 638 | Remote binding, OAuth 2.1 resource server, per-identity bearer list |
12+
| 3 | spec-mcp-3-elicitation | 640 | Server-initiated `elicitation/create`, POST-to-SSE upgrade |
13+
| 4 | spec-mcp-4-tasks | 681 | Task registry, `tasks/*` methods, worker goroutines, mid-task elicit |
14+
| 5 | spec-mcp-5-apps | 682 | Resources capability, `ui://` scheme, embedded UI bundles |
15+
16+
## Decisions
17+
18+
- Phases landed independently. Each was its own spec with its own TDD
19+
cycle and learned summary. The umbrella tracked ordering and cross-
20+
cutting concerns but never went through `/implement` itself.
21+
22+
- The protocol version stayed at `2025-06-18` throughout. Task-augmented
23+
requests use capability negotiation, not a version bump to `2025-11-25`.
24+
25+
- `handler.go` (legacy 2024-11-05) was NOT deleted. `ze-chaos` still
26+
uses the legacy `Handler()` factory. Migration is deferred.
27+
28+
## What Worked
29+
30+
- The phased approach prevented the "partial wiring" trap. Each phase
31+
delivered a self-contained, testable feature with `make ze-verify`
32+
passing before the next phase started.
33+
34+
- The YANG extension pattern (`ze:task-support`, `ze:ui-resource`)
35+
proved composable. Each phase that added tool-descriptor metadata
36+
followed the same walker -> map -> CommandInfo -> buildToolDef chain.
37+
38+
- Session capability bits (`clientElicit`, `clientTasks`, `clientResources`)
39+
kept the capability gate simple: one bool per feature, checked before
40+
dispatch.
41+
42+
## What to Watch
43+
44+
- Auth mode `oauth` (Phase 2) is implemented as resource-server
45+
validation only. Ze does not run an authorization server. The AS
46+
metadata discovery path needs real-world testing with an external AS.
47+
48+
- `resources/updated` notifications and `resources/list` pagination are
49+
deferred. Both become relevant if UI bundles grow or become mutable.
50+
51+
## Files
52+
53+
All files are documented in the per-phase learned summaries (636, 638,
54+
640, 681, 682). The umbrella added no files of its own.

0 commit comments

Comments
 (0)