-
Notifications
You must be signed in to change notification settings - Fork 10
Feature official Go MCP SDK #26
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
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
# Conflicts: # go.mod # go.sum
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.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 migrates the KAgent Tools project from an unofficial MCP SDK (github.com/mark3labs/mcp-go) to the official Model Context Protocol Go SDK (github.com/modelcontextprotocol/go-sdk). The migration includes updates across all tool categories, test files, and server implementation to use the new SDK patterns and APIs.
- Updates all MCP-related imports from
mark3labs/mcp-goto the officialgithub.com/modelcontextprotocol/go-sdk/mcp - Refactors tool registration and handler implementations to match the new SDK's API structure
- Updates test files to work with the new SDK's types and patterns
Reviewed Changes
Copilot reviewed 39 out of 42 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/integration/*.go | New comprehensive integration tests for the MCP SDK migration |
| test/e2e/helpers_test.go | Updated to placeholder MCP client functionality pending new SDK client |
| test/e2e/cli_test.go | Minor cleanup to handle response body closing |
| pkg/utils/*.go | Updated to use new SDK types and patterns for tool registration |
| pkg/prometheus/*.go | Migrated tool handlers and registration to new SDK format |
| pkg/k8s/*.go | Extensive refactoring to use new SDK API structure |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- fix k8s get events format - default wide Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.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
Copilot reviewed 43 out of 46 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| request := &mcp.CallToolRequest{ | ||
| Params: &mcp.CallToolParamsRaw{ | ||
| Name: "datetime_get_current_time", | ||
| Arguments: json.RawMessage(`{}`), | ||
| }, | ||
| } |
Copilot
AI
Oct 3, 2025
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.
The Name field is being set in CallToolParamsRaw but based on the new SDK structure, this field may not be needed or correctly placed. Verify that the tool name is properly configured in the MCP request structure.
pkg/utils/common.go
Outdated
| var args map[string]interface{} | ||
| if err := json.Unmarshal(request.Params.Arguments, &args); err != nil { | ||
| return &mcp.CallToolResult{ | ||
| Content: []mcp.Content{&mcp.TextContent{Text: "failed to parse arguments"}}, |
Copilot
AI
Oct 3, 2025
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.
The error message 'failed to parse arguments' doesn't provide enough context about what went wrong. Consider including the original error details to help with debugging.
| Content: []mcp.Content{&mcp.TextContent{Text: "failed to parse arguments"}}, | |
| Content: []mcp.Content{&mcp.TextContent{Text: fmt.Sprintf("failed to parse arguments: %v", err)}}, |
| }, nil | ||
| } | ||
| defer resp.Body.Close() | ||
| defer func() { _ = resp.Body.Close() }() |
Copilot
AI
Oct 3, 2025
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.
[nitpick] Using anonymous function in defer when a simple method call would suffice adds unnecessary complexity. Consider using defer resp.Body.Close() directly.
| defer func() { _ = resp.Body.Close() }() | |
| defer resp.Body.Close() |
| if _, err := tmpFile.WriteString(manifest); err != nil { | ||
| tmpFile.Close() | ||
| return mcp.NewToolResultError(fmt.Sprintf("Failed to write to temp file: %v", err)), nil | ||
| _ = tmpFile.Close() |
Copilot
AI
Oct 3, 2025
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.
Error handling is being silently ignored. If this fails, it could indicate a serious problem with file system operations. Consider logging the error or handling it appropriately.
| _ = tmpFile.Close() | |
| if closeErr := tmpFile.Close(); closeErr != nil { | |
| logger.Get().Error("Failed to close temp file after write error", "error", closeErr, "file", tmpFile.Name()) | |
| } |
| func createCallToolRequest(args map[string]interface{}) *mcp.CallToolRequest { | ||
| argsJSON, _ := json.Marshal(args) | ||
| return &mcp.CallToolRequest{ | ||
| Params: &mcp.CallToolParamsRaw{ | ||
| Arguments: argsJSON, | ||
| }, | ||
| } | ||
| } |
Copilot
AI
Oct 3, 2025
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.
The json.Marshal error is being silently ignored with _. In test code, this could lead to subtle bugs if marshaling fails. Consider handling the error or using require.NoError in the test context.
| return mcp.NewToolResultError("resource_type, resource_name, and annotation_key parameters are required"), nil | ||
| } | ||
| // RegisterTools registers all k8s tools with the MCP server | ||
| func RegisterTools(server *mcp.Server, llm llms.Model, kubeconfig string) error { |
Copilot
AI
Oct 3, 2025
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.
The function signature accepts an llm parameter but it's not used in most of the registered tools. Consider if this parameter is still needed or if it should be optional for tools that don't require LLM functionality.
- allow filter tools in helm - fix k8s get events format - default wide Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
- fix k8s get events format - default wide - added helm template - added argocd cli Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
|
latest argo-rollouts cli has several CVE's
|
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
Copilot reviewed 57 out of 61 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| t.Log("✅ HTTP Error Handling test PASSED (implementation complete)") | ||
| } | ||
|
|
||
| // createHTTPTransport creates an HTTP transport for testing |
Copilot
AI
Oct 29, 2025
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.
The function createHTTPTransport is declared in the comment on line 333 but its implementation is not shown in the diff. This appears to be an incomplete code snippet. Ensure the function implementation is included or the comment should be removed if the function is defined elsewhere.
| } | ||
|
|
||
| func TestHelmInstall(t *testing.T) { | ||
| releaseName := "test-release" |
Copilot
AI
Oct 29, 2025
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.
Changed Helm chart reference from bitnami/nginx to chainguard/nginx. Ensure that the chainguard/nginx chart is consistently available and accessible in test environments. If this change is intentional for security or reliability reasons, consider documenting the rationale.
| releaseName := "test-release" | |
| releaseName := "test-release" | |
| // Using 'chainguard/nginx' chart instead of 'bitnami/nginx' for improved security and reliability. | |
| // Ensure the 'chainguard' Helm repository is added and accessible in test environments. |
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Resolves TODO in cmd/main.go line 253 by implementing ToolRegistry support for all tool providers (k8s, helm, istio, argo, cilium, prometheus). Changes: - Added ToolRegistry interface to all tool providers - Created RegisterToolsWithRegistry functions alongside existing RegisterTools - Updated main.go to pass ToolRegistry to all providers in HTTP mode - HTTP transport now discovers and executes tools from all providers - Backward compatibility maintained for stdio mode (registry is optional) HTTP Transport Verification: - Server starts successfully with all tool providers - Tool discovery endpoint lists all registered tools (29 tools from k8s+helm+istio tested) - Tool execution works correctly via HTTP POST - All tools properly registered with both MCP server and ToolRegistry Closes #TODO-253
8b7da30 to
dfb4a39
Compare
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
dfb4a39 to
ab024aa
Compare
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
Copilot reviewed 65 out of 73 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| t.Log("✅ HTTP Error Handling test PASSED (implementation complete)") | ||
| } | ||
|
|
||
| // createHTTPTransport creates an HTTP transport for testing |
Copilot
AI
Nov 4, 2025
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.
The comment indicates a function definition should follow, but the actual function implementation is missing from the diff. This appears to be an incomplete code block that would cause compilation errors.
| // createHTTPTransport creates an HTTP transport for testing | |
| // createHTTPTransport creates an HTTP transport for testing | |
| func createHTTPTransport(serverURL string) mcp.Transport { | |
| return mcp.NewHTTPTransport(serverURL, nil) | |
| } |
- http transport fixes Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
✅ TOOLS_ISTIO_VERSION=1.28.0 == 1.28.0 ✅ TOOLS_HELM_VERSION=3.19.1 == v3.19.1 Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.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
Copilot reviewed 59 out of 77 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
pkg/utils/common.go:1
- [nitpick] Empty line 200 appears unnecessary between the condition check and the comment. Remove for cleaner code formatting.
// Package utils provides common utility functions and tools.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Version: "1.0.0", | ||
| }, nil) | ||
|
|
||
| // Create HTTP transport for the MCP server |
Copilot
AI
Nov 12, 2025
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.
The StreamableClientTransport struct initialization lacks context. Consider adding a comment explaining that this transport connects to the MCP server running in the Kubernetes cluster via NodePort 30885.
| // Create HTTP transport for the MCP server | |
| // Create HTTP transport for the MCP server | |
| // This transport connects to the MCP server running in the Kubernetes cluster via NodePort 30885. |
| if _, err := tmpFile.WriteString(manifest); err != nil { | ||
| tmpFile.Close() | ||
| return mcp.NewToolResultError(fmt.Sprintf("Failed to write to temp file: %v", err)), nil | ||
| _ = tmpFile.Close() |
Copilot
AI
Nov 12, 2025
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.
[nitpick] Error from tmpFile.Close() is silently discarded. Since this is in an error path where file writing failed, this is acceptable. However, consider logging this error for better debugging.
| _ = tmpFile.Close() | |
| if closeErr := tmpFile.Close(); closeErr != nil { | |
| logger.Get().Error("Failed to close temporary file after write error", "error", closeErr, "file", tmpFile.Name()) | |
| } |
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
Migrated to Official Go MCP SDK