Skip to content

Commit ff50385

Browse files
committed
fix(mcp): hide the plugins state from agents while a plugin's tools are off
The pangular:plugins key holds every page plugin's view and can't be filtered per plugin, so HTTP MCP hides it while any plugin has its tools turned off. The panel still reads it.
1 parent 7568797 commit ff50385

4 files changed

Lines changed: 39 additions & 19 deletions

File tree

‎apps/docs/src/content/agents/resources.md‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ The HTTP endpoint leaves out the keys of an inspector whose agent tools are hidd
8888

8989
This table covers the data that has no resource of its own.
9090

91-
| Key | Content |
92-
| --------------------------- | ----------------------------------------------------------------------- |
93-
| `pangular:http` | The SSR & HTTP timeline, SSR requests, fault rules and hydration data |
94-
| `pangular:http-payloads` | The TransferState payload of each page, by page id |
95-
| `pangular:change-detection` | Change detection recordings, by page id |
96-
| `pangular:pipe-usage` | Live pipe instances and recorded calls |
97-
| `pangular:errors` | Error groups and console calls, by page id |
98-
| `pangular:leaks` | Leak hints: retained instances, open subscriptions, effects, by page id |
99-
| `pangular:startup` | Startup timing: milestones and the slowest providers, by page id |
100-
| `pangular:plugins` | Plugin views by page id, and the server plugins with their tools |
101-
| `pangular:plugin.<id>` | A server plugin's own state, hidden with that plugin's tools |
102-
| `pangular:audit` | Audit sessions and axe passes: when each was taken, by page id |
103-
| `pangular:analog` | Analog page data and the server call log |
104-
| `pangular:routes` | Declared but not filled. Use `get-routes` or `list-routes` instead. |
91+
| Key | Content |
92+
| --------------------------- | --------------------------------------------------------------------------------------------------------- |
93+
| `pangular:http` | The SSR & HTTP timeline, SSR requests, fault rules and hydration data |
94+
| `pangular:http-payloads` | The TransferState payload of each page, by page id |
95+
| `pangular:change-detection` | Change detection recordings, by page id |
96+
| `pangular:pipe-usage` | Live pipe instances and recorded calls |
97+
| `pangular:errors` | Error groups and console calls, by page id |
98+
| `pangular:leaks` | Leak hints: retained instances, open subscriptions, effects, by page id |
99+
| `pangular:startup` | Startup timing: milestones and the slowest providers, by page id |
100+
| `pangular:plugins` | Plugin views by page id, and the server plugins with their tools. Hidden while any plugin's tools are off |
101+
| `pangular:plugin.<id>` | A server plugin's own state, hidden with that plugin's tools |
102+
| `pangular:audit` | Audit sessions and axe passes: when each was taken, by page id |
103+
| `pangular:analog` | Analog page data and the server call log |
104+
| `pangular:routes` | Declared but not filled. Use `get-routes` or `list-routes` instead. |
105105

106106
The list also includes the keys behind the six resources above (`pangular:component-tree`, `pangular:forms`, and so on).
107107

‎apps/docs/src/content/getting-started/configuration.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ The overlay reads the option from the server when it connects, so the default wo
233233

234234
`inspectors.plugins: false` turns every [Pangular plugin](../guides/write-a-plugin.md) off: the **Plugins** tab, the page plugins, the server plugins' tools and state. `plugins` turns one plugin off, by its id, or only part of it:
235235

236-
| Option | Default | What `false` turns off |
237-
| ---------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
238-
| `plugins.<id>` | `true` | The plugin: the page doesn't run it, and its tools and state are not registered. |
239-
| `plugins.<id>.tools` | `true` | The plugin's agent tools, its shared state over HTTP MCP, and the plugin in `list-plugins` and `inspect-plugin` answers. Its view stays in the panel. |
240-
| `plugins.<id>.actions` | `true` | The plugin's page actions and its tools that are not `read`. |
236+
| Option | Default | What `false` turns off |
237+
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
238+
| `plugins.<id>` | `true` | The plugin: the page doesn't run it, and its tools and state are not registered. |
239+
| `plugins.<id>.tools` | `true` | The plugin's agent tools, its shared state over HTTP MCP, and the plugin in `list-plugins` and `inspect-plugin` answers. The `pangular:plugins` state, which holds every plugin's view, is hidden from HTTP MCP too. Its view stays in the panel. |
240+
| `plugins.<id>.actions` | `true` | The plugin's page actions and its tools that are not `read`. |
241241

242242
```ts
243243
// src/server.ts

‎packages/devtools/src/__tests__/plugins-server.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ describe('plugin config', () => {
163163
const off = resolvePangularConfig({ plugins: { travel: { tools: false } } });
164164
expect(sharedStateExposed('pangular:plugin.travel', off)).toBe(false);
165165
expect(sharedStateExposed('pangular:plugin.query', off)).toBe(true);
166+
// The aggregate key holds every plugin's view, so it hides with any plugin's tools.
167+
expect(sharedStateExposed('pangular:plugins', off)).toBe(false);
168+
expect(sharedStateExposed('pangular:plugins', resolvePangularConfig({}))).toBe(true);
169+
expect(
170+
sharedStateExposed(
171+
'pangular:plugins',
172+
resolvePangularConfig({ plugins: { travel: { actions: false } } }),
173+
),
174+
).toBe(true);
175+
expect(
176+
sharedStateExposed(
177+
'pangular:plugins',
178+
resolvePangularConfig({ agent: { tools: { plugins: false } } }),
179+
),
180+
).toBe(false);
166181
});
167182
});
168183

‎packages/devtools/src/config.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,11 @@ export function sharedStateExposed(key: string, config: ResolvedPangularConfig):
11921192
if (!key.startsWith('pangular:')) return true;
11931193
const name = agentName(key);
11941194
if (SHARED_STATE_KEYS.includes(name)) return true;
1195+
// Every page plugin's view, in one key: shown only while no plugin has its
1196+
// tools turned off, since a key can't be filtered per plugin.
1197+
if (name === 'plugins' && config.agent.tools.plugins) {
1198+
return Object.keys(config.plugins ?? {}).every((id) => pluginSwitches(id, config).tools);
1199+
}
11951200
// A server plugin's own state, `plugin.<id>`.
11961201
const plugin = /^plugin\.(.+)$/.exec(name)?.[1];
11971202
if (plugin !== undefined) return pluginSwitches(plugin, config).tools;

0 commit comments

Comments
 (0)