Skip to content

Introduce getKubernetesResourceStripped operation #30

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

Merged
merged 5 commits into from
Jun 30, 2025

Conversation

deviantony
Copy link
Member

Introduce getKubernetesResourceStripped to retrieve a lighter version of the Kubernetes response for GET operations.

…s resource retrieval

- Updated version in tools.yaml from v1.1 to v1.2.
- Introduced a new tool, 'getKubernetesResourceStripped', for proxying GET requests to Kubernetes resources while stripping verbose metadata for a leaner payload.
- Enhanced tool parameters and descriptions for clarity and usability.
…tests

- Bumped Go version in go.mod to 1.24.2 and added new dependencies for Kubernetes API handling.
- Introduced a new tool handler for 'getKubernetesResourceStripped' to validate parameters and process requests.
- Enhanced test coverage with new validation tests for the Kubernetes proxy, ensuring robust error handling and response processing.
- Updated go.sum to reflect changes in dependencies and ensure compatibility.
- Deleted the tools.yaml file, which contained various tool definitions and annotations for Portainer.
- Added multiple test cases to validate the handling of various Kubernetes API response scenarios, including empty objects, lists with mixed items, and objects with complex metadata.
- Implemented tests for error conditions and edge cases, ensuring robust error handling and response processing.
- Improved coverage for cases involving managedFields, ensuring they are correctly removed while preserving other metadata.
- Removed outdated test cases and added new scenarios to validate error handling for various object structures, including empty maps and malformed metadata.
- Improved coverage for edge cases, ensuring robust processing of Kubernetes API responses and proper error reporting.
- Updated the `ProcessRawKubernetesAPIResponse` function to continue processing items in lists even when errors occur, enhancing resilience.
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/portainer/portainer-mcp/internal/k8sutil 91.30% (+91.30%) 🌟
github.com/portainer/portainer-mcp/internal/mcp 90.09% (+0.41%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/portainer/portainer-mcp/internal/k8sutil/stripper.go 91.30% (+91.30%) 46 (+46) 42 (+42) 4 (+4) 🌟
github.com/portainer/portainer-mcp/internal/mcp/kubernetes.go 95.89% (+0.65%) 73 (+31) 70 (+30) 3 (+1) 👍
github.com/portainer/portainer-mcp/internal/mcp/schema.go 100.00% (ø) 2 2 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/portainer/portainer-mcp/internal/k8sutil/stripper_test.go
  • github.com/portainer/portainer-mcp/internal/mcp/kubernetes_test.go

@deviantony deviantony merged commit c8f0d45 into main Jun 30, 2025
2 checks passed
@deviantony deviantony deleted the k8s-response-size branch June 30, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant