You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b0e1f2b
Browse filesBrowse the repository at this point in the historyBrowse files
feat(mcp): serve per-page resource templates and list_changed (#417)
Agents can read one page's component tree, signal graph, injector tree, NgRx store, forms or router as pangular://page/{pageId}/<name>, and get resources list_changed when a page connects or goes away. devframe 1.2.5 has no resource templates, so the local patches gain resourceTemplates and onResourcesChanged route options, like prompts.
Refs #372.
Copy file name to clipboardExpand all lines: apps/docs/src/content/agents/mcp-server.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,6 +259,10 @@ The argument is your own text. The server puts it on one line, cuts it at 200 ch
259
259
260
260
The stdio server offers no prompts. Like the instructions, the prompts need a devframe patch that devframe 1.2.5 does not ship, so an installed package offers none until devframe ships it.
261
261
262
+
### Resource templates
263
+
264
+
The HTTP endpoint also lists a resource template for each page-scoped resource, such as `pangular://page/{pageId}/component-tree`, and sends `notifications/resources/list_changed` when a page starts reporting or expires. See [Read one page](./resources.md#read-one-page).
265
+
262
266
### Tool names
263
267
264
268
The server registers tools with a colon, as `pangular:get-routes`. MCP clients see them with an underscore, as `pangular_get-routes`. Calls with either form work.
Copy file name to clipboardExpand all lines: apps/docs/src/content/agents/resources.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,37 @@ Every form the page reported (Signal Forms, reactive and template-driven), with
78
78
79
79
The active route tree (params, data, guards, resolvers) and recent navigations of each page. When the data is too large, the resource returns the URL and recent navigations of each page, and points to `inspect-route`, `explain-navigation` and `list-routes`.
80
80
81
+
## Read one page
82
+
83
+
The six resources above hold every connected page. When several tabs or apps are connected, read one page through its own resource instead.
84
+
85
+
### Page resource templates
86
+
87
+
The HTTP endpoint lists one *MCP resource template per resource in `resources/templates/list`. Put a page id from [`list-pages`](./tools.md#list-pages) in the URI:
Each one returns the JSON of its resource with only that page in it, with the same `_untrusted` field and the same summary when it is too large. The selection made in the panel (`selectedId` and the like) is left out, since it belongs to no page. If no page with that id reports the data, the answer is a markdown note that lists the pages that do.
99
+
100
+
A template follows its resource: it is left out when the inspector is off through `inspectors` or `agent.tools`.
101
+
102
+
### Per-page entries in the list
103
+
104
+
Some clients don't read templates. For them, `resources/list` also names one resource per reporting page, such as `pangular://page/<pageId>/component-tree`.
105
+
106
+
### List changes
107
+
108
+
When a page starts reporting or expires, the server sends `notifications/resources/list_changed`, so a client can list the resources again. Changes settle for half a second first, and a report from a page that is already listed sends nothing.
109
+
110
+
Like the prompts, the templates need a devframe patch that devframe 1.2.5 does not ship. The stdio server has no templates, since no page connects to it.
111
+
81
112
## Shared state
82
113
83
114
The devtools keep their live data in shared-state keys. Every key is also listed as a resource, at `devframe://state/<key>` with the key encoded.
Copy file name to clipboardExpand all lines: apps/docs/src/content/contributing/development.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,15 +45,16 @@ pnpm install
45
45
46
46
`patches/` holds `pnpm patch` changes to the built files of `devframe`, `@devframes/agentic` and `@devframes/hub` 1.2.5, listed under `patchedDependencies` in `pnpm-workspace.yaml`. They add what devframe doesn't ship:
|`instructions`| An MCP route option, sent as `instructions` in the `initialize` result. Patched in `devframe`, `@devframes/hub` and `@devframes/agentic`. |`pangularMcp()` in `packages/devtools/src/agent-mcp.ts`|
51
-
|`prompts`| An MCP route option with prompt templates. `@devframes/agentic` declares the `prompts` capability and answers `prompts/list` and `prompts/get` (invalid params for an unknown prompt or a missing required argument). Patched in `devframe`, `@devframes/hub` and `@devframes/agentic`. |`pangularMcpPrompts()` in `packages/devtools/src/agent-prompts.ts`, through `pangularMcp()`|
52
-
|`mcpContent` answers |`@devframes/agentic` sends a tool result's `mcpContent` blocks (`text` and `image`) as the MCP content, instead of the result as JSON. |`screenshot-component`, through `withMcpContent()` in `rpc/component-screenshots.ts`|
|`instructions`| An MCP route option, sent as `instructions` in the `initialize` result. Patched in `devframe`, `@devframes/hub` and `@devframes/agentic`. |`pangularMcp()` in `packages/devtools/src/agent-mcp.ts`|
51
+
|`prompts`| An MCP route option with prompt templates. `@devframes/agentic` declares the `prompts` capability and answers `prompts/list` and `prompts/get` (invalid params for an unknown prompt or a missing required argument). Patched in `devframe`, `@devframes/hub` and `@devframes/agentic`. |`pangularMcpPrompts()` in `packages/devtools/src/agent-prompts.ts`, through `pangularMcp()`|
52
+
|`resourceTemplates`| MCP route options for resource templates and a host hook for resource list changes. `@devframes/agentic` answers `resources/templates/list`, reads a URI through the first template that matches it (`{name}` variables only, one URI segment each), adds each template's `list()` entries to `resources/list`, and sends `notifications/resources/list_changed` when `onResourcesChanged` calls back. Patched in `devframe`, `@devframes/hub` and `@devframes/agentic`. |`pangularMcpResourceTemplates()` and `pangularMcpPagesChanged()` in `packages/devtools/src/agent-page-resources.ts`, through `pangularMcp()`|
53
+
|`mcpContent` answers |`@devframes/agentic` sends a tool result's `mcpContent` blocks (`text` and `image`) as the MCP content, instead of the result as JSON. |`screenshot-component`, through `withMcpContent()` in `rpc/component-screenshots.ts`|
53
54
54
55
The `exposeSharedState` filter, which hides the shared-state keys of an inspector with `agent.tools.<name>: false`, is part of devframe since 1.2.4 and needs no patch.
55
56
56
-
The patches apply only inside this repository. An app that installs the published package gets no server `instructions`and no prompts, and `screenshot-component` answers with its text note only, until devframe ships them. Each patch names an exact version and file names with build hashes, so a devframe upgrade needs the patches redone with `pnpm patch`, or removed once devframe has the feature.
57
+
The patches apply only inside this repository. An app that installs the published package gets no server `instructions`, no prompts and no page resource templates, and `screenshot-component` answers with its text note only, until devframe ships them. Each patch names an exact version and file names with build hashes, so a devframe upgrade needs the patches redone with `pnpm patch`, or removed once devframe has the feature.
Copy file name to clipboardExpand all lines: docs/CONTEXT.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ An MCP prompt: a ready request for one workflow, such as `debug-error` or `fix-f
93
93
_Avoid_: template, command, skill (a skill is a `SKILL.md` folder the agent reads)
94
94
95
95
**Resource**:
96
-
Live state an agent reads as JSON over MCP, such as `pangular:component-tree`. It holds what the connected pages reported, so it is empty when no page is connected.
96
+
Live state an agent reads as JSON over MCP, such as `pangular:component-tree`. It holds what the connected pages reported, so it is empty when no page is connected. Each page-scoped resource also has a per-page resource template, `pangular://page/{pageId}/<name>`, that holds one page (`packages/devtools/src/agent-page-resources.ts`).
0 commit comments