feat(plugins): report implemented MCP tools at load

The child adds the tool names its mcpToolProvider hook implements to the
loaded payload, beside routes/jobs/exports, and the supervisor caches
them on Supervised like the rest. The hook itself already rides the
existing Object.keys(def.hooks) line, so the "did the child report the
hook too" half was free.

Declarative and synchronous: the host never asks the child what tools it
has. It intersects this list with the signed manifest, so a build that
reports a tool the manifest never declared is ignored rather than
trusted.

grantsOf comes along because the advertise path has to clamp what a
tool's annotations may claim against what the plugin was actually
granted, and sup.granted is already in memory. A per-tool DB read would
be the alternative.

plugin-host-entry.ts is excluded from coverage (it runs in a forked
subprocess), so the two supervisor integration cases are the only thing
proving any of this: the loaded payload, the acting-user-bound invoke,
and that both stop the moment the plugin is no longer active.
This commit is contained in:
Renzo Beux
2026-08-28 13:43:28 -03:00
committed by Maurice
parent 29de8dd9c1
commit c6027f9e68
4 changed files with 76 additions and 1 deletions
@@ -946,6 +946,14 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDes
routesOf(id: string): PluginRouteInfo[] {
return this.supervisor.routesOf(id);
}
/** MCP tool names an active plugin reported implementing at load. */
mcpToolsOf(id: string): string[] {
return this.supervisor.mcpToolsOf(id);
}
/** The grants an active plugin holds, for clamping what its tools may claim. */
grantsOf(id: string): ReadonlySet<string> {
return this.supervisor.grantsOf(id);
}
invoke(id: string, method: string, params: Record<string, unknown>, actingUserId?: number): Promise<unknown> {
return this.supervisor.invoke(id, method, params, { actingUserId });
}