Fix Missing Kubernetes API Routes for MCP#351
Merged
Conversation
- Implemented new handlers in `pkg/fwdapi/handlers/kubernetes.go` to support endpoints for pod logs, pod listing, pod details, events, and service endpoints. - Included parameter validation and error responses for missing or invalid inputs.
…atches - Added logic to search for services when `Namespace` is not provided. - Implemented filtering for exact matches and error-handling for ambiguous namespace cases. - Simplified key construction logic for connection info retrieval.
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (3.71%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #351 +/- ##
==========================================
- Coverage 61.85% 60.64% -1.22%
==========================================
Files 69 69
Lines 11583 11817 +234
==========================================
+ Hits 7165 7166 +1
- Misses 4124 4355 +231
- Partials 294 296 +2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed 5 missing HTTP API routes that MCP tools were calling but didn't exist, plus fixed response format issues and improved
get_connection_infobehavior.Problem
MCP tools had HTTP clients calling endpoints that were never registered on the API server, resulting in 404 errors. The HTTP client code existed, the backend implementations existed in
adapters.go, but the routes were never connected.Changes
1. Added 5 Missing Route Handlers (
pkg/fwdapi/handlers/kubernetes.go)GetPodLogsGET /v1/kubernetes/pods/:namespace/:podName/logsListPodsGET /v1/kubernetes/pods/:namespaceGetPodGET /v1/kubernetes/pods/:namespace/:podNameGetEventsGET /v1/kubernetes/events/:namespaceGetEndpointsGET /v1/kubernetes/endpoints/:namespace/:serviceName2. Registered Routes (
pkg/fwdapi/server.go)Added 5 route registrations after existing kubernetes routes:
3. Fixed Response Format Issues (
pkg/fwdapi/handlers/kubernetes.go)ListPods: Changed fromData: map[string]interface{}{"pods": pods}toData: podsGetEvents: Changed fromData: map[string]interface{}{"events": events}toData: eventsThe HTTP clients expected arrays directly in
Data, not wrapped in objects.4. Fixed
get_connection_infoWithout Namespace (pkg/fwdmcp/tools.go)When namespace is not provided, the handler now:
FindServicesto search for the service by namePreviously it would construct an incomplete key (just service name) which always returned 404.
Files Modified
pkg/fwdapi/handlers/kubernetes.go- Added 5 handler methods, addedstrconvimportpkg/fwdapi/server.go- Added 5 route registrationspkg/fwdmcp/tools.go- FixedhandleGetConnectionInfoto search when namespace not providedTesting
MCP Tools Now Working
get_pod_logs- Get container logs from podslist_pods- List pods in a namespaceget_pod- Get detailed pod informationget_events- Get Kubernetes eventsget_endpoints- Get service endpointsget_connection_info- Now works with just service name (searches for it)