Repository navigation
fix(ai-assistant): use MCP server's manifest description in approval dialog instead of hardcoded "Inspektor Gadget" fallback - #1097
Conversation
3124ce8 to
0608c2d
Compare
illume
left a comment
There was a problem hiding this comment.
Thanks for these changes.
Can you please have a look at the git commits to see if they meet the contribution guidelines? We use a Linux kernel style of git commits. See the contributing guide for general context, and please see previous git commits with git log for examples.
Commits that need attention
fix(ai-assistant): thread MCP manifest description into approval dialog— Missingarea: descriptionprefix — e.g.frontend: HomeButton: Fix so it navigates to homeorbackend: config: Add enable-dynamic-clusters flag.
Commit guidelines
- Use atomic commits focused on a single change.
- Use the title format
<area>: <Description of changes>— description must start with a capital letter. - Keep the title under 72 characters (soft requirement).
- Explain the intention and why the change is needed.
- Make commit titles meaningful and describe what changed.
- Do not add code that a later commit rewrites; squash or reorder commits instead.
- Do not include
Fixes #NNin commit messages.
Good examples:
frontend: HomeButton: Fix so it navigates to homebackend: config: Add enable-dynamic-clusters flag
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The multi-tool orchestration approval path still uses an LLM-generated description instead of authoritative MCP metadata.
Review effort: Balanced
Findings: 1
What changed in this PR
Updates MCP approval dialogs to prefer server-provided tool descriptions over Gadget-specific heuristics.
Changes:
- Adds optional catalog descriptions and a generic MCP fallback.
- Threads descriptions through direct and streaming approval paths.
- Adds unit tests for precedence and fallback behavior.
| File | Description |
|---|---|
getToolDescription.ts |
Adds manifest-description support and generic fallback. |
getToolDescription.test.ts |
Tests description precedence and fallbacks. |
LangChainAssistantSession.ts |
Passes MCP metadata into approval descriptions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| id: tc.id, | ||
| name: toolName, | ||
| description: this.getToolDescription(toolName, isMCPTool), | ||
| description: this.getToolDescription(toolName, isMCPTool, mcpToolEntry?.description), |
There was a problem hiding this comment.
Addressed in the latest rebased commit. In handleMultipleToolExecution(), we now resolve the matching RuntimeToolInfo from this.toolManager.getMCPTools() and route it through getToolDescription(toolName, isMCPTool, mcpToolEntry?.description). This ensures manifest descriptions take precedence over planner LLM output during multi-tool execution approvals. Added a unit test in LangChainAssistantSession.test.ts covering this path.
illume
left a comment
There was a problem hiding this comment.
Thanks for the contribution.
There are some open Copilot review comments — could you take a look at them? Please mark each one as resolved once you've addressed it.
0608c2d to
b4cee74
Compare
The tool approval dialog showed "Inspektor Gadget debugging tool: toolname" for every MCP tool whose name did not match a small set of Inspektor Gadget-specific keywords (exec, run, trace, etc.). Non-Gadget MCP servers such as Flux, Prometheus, or custom tools were all affected. Root cause: getToolDescription() only received a toolName string and a boolean isMCPTool flag. The MCP server's own description — already stored in RuntimeToolInfo.description and available in every getMCPTools() call — was never threaded through to the function. Additionally, multi-tool orchestration approval used LLM-generated descriptions rather than manifest descriptions. Fix: - Add an optional catalogDescription?: string third param to getToolDescription(). When present for an MCP tool it is returned immediately, before any keyword heuristic runs (backward-compatible: all existing callers that omit the param keep their current behavior). - Replace the hardcoded "Inspektor Gadget debugging tool: toolname" catch-all with the generic "MCP tool: toolname". - At all approval construction sites in LangChainAssistantSession (direct, streaming, and multi-tool orchestration), capture the full RuntimeToolInfo object from getMCPTools() and pass mcpToolEntry?.description as the third argument. - Update getToolDescription.test.ts: fix stale 'Inspektor Gadget' assertion; add tests for catalog-description priority and empty-string fallback behavior. - Add unit test in LangChainAssistantSession.test.ts verifying orchestrated tools use MCP manifest descriptions in approval dialogs. Signed-off-by: Saksham842 <sakshamhans5492@gmail.com>
b4cee74 to
ccdbf74
Compare
|
Thanks for the review @illume!
|

What does this PR do?
Fixes the MCP tool approval dialog showing
"Inspektor Gadget debugging tool: <name>"for every non-Gadget MCP server (Flux, Prometheus, Vault, custom tools, etc.).Closes #1096
Problem
getToolDescription()inpackages/ai-common/src/tools/catalog/getToolDescription.tsused keyword heuristics tuned to Inspektor Gadget naming conventions, with a catch-all fallback that hardcoded the "Inspektor Gadget" brand name:The MCP server's own tool description was already stored in
RuntimeToolInfo.descriptionat thegetMCPTools()call sites — but it was never threaded through togetToolDescription. Every non-Gadget MCP tool therefore showed completely wrong text in the human approval dialog.Solution
getToolDescription.ts— added an optionalcatalogDescription?: stringthird parameter. When present for an MCP tool it is returned immediately, before any keyword heuristic runs. The"Inspektor Gadget"catch-all is replaced with the generic"MCP tool: <name>":LangChainAssistantSession.ts— bothtoolCallsForApprovalconstruction sites changed from.some()→.find()to capture the fullRuntimeToolInfoobject, then passmcpToolEntry?.descriptionas the third argument. The privategetToolDescriptionwrapper is updated to forward the new parameter.getToolDescription.test.ts— updated the stale'Inspektor Gadget'fallback assertion; added two new tests:runin its name)Before / After
flux__reconcile_kustomization(manifest desc: "Reconcile a Flux Kustomization object")"Inspektor Gadget debugging tool: flux__reconcile_kustomization""Reconcile a Flux Kustomization object""Inspektor Gadget debugging tool: some__tool""MCP tool: some__tool"gadget__trace_open, no manifest description"Traces system calls and processes for debugging"Checklist
getToolDescription.test.ts— 11/11 )LangChainAssistantSession.ts— both approval construction sites updated consistentlyFiles changed
packages/ai-common/src/tools/catalog/getToolDescription.tscatalogDescriptionparam; replaced Gadget fallbackpackages/ai-common/src/assistant/LangChainAssistantSession.tsmcpToolEntry?.descriptionat both call sitespackages/ai-common/src/tools/catalog/getToolDescription.test.ts