mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 23:16:46 +00:00
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:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user