-
-
Notifications
You must be signed in to change notification settings - Fork 5
fix: enhance tool generation and execution with improved flag handling and logging #1982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…g and logging - Add ItemsType to FlagDef for JSON schema array items. - Filter parameters in handleConsolidatedTool to prevent unknown flag errors. - Implement detailed logging for command execution and failures. - Introduce tests for array parameters and excluded commands. - Update ToolOptions to include a logger for debug logging. Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
✅
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…es; optimize component count logic Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR hardens MCP tool generation and execution by fixing JSON schema array definitions, excluding meta commands and their children from tool generation, and adding structured logging to command execution, while also tuning installer timeouts.
Changes:
- Ensure all array-typed tool parameters include proper JSON Schema
itemsdefinitions and add tests to guard against regressions, fixing MCP validation errors. - Improve consolidated tool handling by filtering parameters to only those applicable to the chosen subcommand and by excluding meta commands (e.g.,
ksail completion,ksail mcp) and their children from tool generation. - Wire an optional
slog.Loggerthrough MCP server and tool execution for detailed debug/error logging, and introduce a dedicated cert-manager install timeout, plus a small cleanup to component counting.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pkg/svc/mcp/server.go |
Passes the configured logger into toolgen options so MCP-executed commands emit structured debug/error logs. |
pkg/svc/installer/helpers.go |
Adds a dedicated CertManagerInstallTimeout constant to allow cert‑manager installs extra time. |
pkg/cli/setup/post_cni.go |
Simplifies ComponentRequirements.Count() using a boolean slice while still counting all component flags, including ArgoCD and Flux. |
pkg/cli/setup/components.go |
Centralizes installer error variables (including CSI and policy engine) and updates the cert‑manager factory to use the new minimum timeout while keeping test expectations intact. |
pkg/ai/toolgen/options.go |
Extends ToolOptions with an optional *slog.Logger used during command execution, keeping default options unchanged aside from the new field. |
pkg/ai/toolgen/mcp.go |
Enhances MCP error responses to include both command output and the wrapped error (with exit code), improving diagnosability for failed tool calls. |
pkg/ai/toolgen/generator.go |
Adds prefix-based exclusion of commands and their children (e.g., ksail completion …), introduces ItemsType for flags, and ensures consolidated-tool schemas emit array types with proper items. |
pkg/ai/toolgen/definition.go |
Extends FlagDef with an ItemsType field so array flags can carry their element JSON Schema type into consolidated schemas. |
pkg/ai/toolgen/executor.go |
Filters consolidated-tool parameters to only those flags defined for the selected subcommand to avoid “unknown flag” errors, and adds structured logging around command execution and failures. |
pkg/ai/toolgen/generator_test.go |
Adds regression tests verifying all array parameters define items with allowed types and that excluded commands (chat, mcp, completion, help) and their children are not generated as tools. |
pkg/ai/toolgen/executor_test.go |
Extends consolidated execution tests to assert that flags not applicable to the chosen subcommand are filtered out, preventing MCP-driven invocations from failing on inapplicable defaults. |
…nce array parameter validation in tests Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
…istency Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>

Enhancements include improved flag handling to prevent unknown flag errors and detailed logging for command execution and failures. Tests for array parameters and excluded commands were also introduced to ensure robustness.
Type of change