Skip to content

Adding kubernetes tools#23

Merged
sajeerzeji merged 2 commits into
toolpack-ai:mainfrom
venmanyarun:kubernetes_tools
Apr 12, 2026
Merged

Adding kubernetes tools#23
sajeerzeji merged 2 commits into
toolpack-ai:mainfrom
venmanyarun:kubernetes_tools

Conversation

@venmanyarun
Copy link
Copy Markdown
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Explain how to reproduce the testing environment.

  • npm run test
  • Specific tool test (e.g., npm run test:tools:fs)
  • Manual testing (describe below)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (run npm run lint)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@venmanyarun venmanyarun requested a review from sajeerzeji April 11, 2026 03:19
Comment thread packages/toolpack-sdk/src/tools/k8s-tools/tools.ts Outdated
Copy link
Copy Markdown
Contributor

@sajeerzeji sajeerzeji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review: Input Validation Gaps (Medium)
Several tools accept user input directly into shell commands without sanitization:

k8sDeleteResourceTool: args.resource, args.name
k8sDescribeTool: args.resource, args.name
k8sSwitchContextTool: args.context
Risk: Potential command injection if untrusted input is passed.

Fix: Add input validation regex or use array-based command construction more carefully.

Comment thread packages/toolpack-sdk/src/tools/k8s-tools/tools.ts Outdated
@sajeerzeji
Copy link
Copy Markdown
Contributor

sajeerzeji commented Apr 11, 2026

AI Review: Suggested Improvements (Non-blocking), Maybe as another PR

  1. Add JSON output option: Most tools output text; add -o json option for programmatic use
  2. Better error messages: Parse kubectl errors to provide more actionable feedback
  3. Dry-run support: For apply_manifest and delete_resource, add --dry-run option
  4. Label selector helper: The labels parameter uses kubectl syntax; consider a structured alternative

@venmanyarun
Copy link
Copy Markdown
Contributor Author

AI Review: Suggested Improvements (Non-blocking), Maybe as another PR

  1. Add JSON output option: Most tools output text; add -o json option for programmatic use
  2. Better error messages: Parse kubectl errors to provide more actionable feedback
  3. Dry-run support: For apply_manifest and delete_resource, add --dry-run option
  4. Label selector helper: The labels parameter uses kubectl syntax; consider a structured alternative

Updated Kubernetes tools

  • Switched kubectl execution to execFileSync for safer array-based command execution.
  • Added parsing and formatting for kubectl errors
  • Added support for:
  • k8s.list_pods
  • k8s.list_services
  • k8s.list_deployments
  • k8s.get_namespaces

Added structured label selector support for:

  • k8s.list_pods
  • k8s.list_deployments

Added dryRun support for:

  • k8s.apply_manifest
  • k8s.delete_resource

Added stronger argument validation on resource/name/context/namespace values.
Schema support update object schemas can be represented.

@sajeerzeji sajeerzeji merged commit 2f4c0d8 into toolpack-ai:main Apr 12, 2026
6 checks passed
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.

2 participants