Skip to content

Add parameter validation for patch_type and output format in kubectl tools #101

@KaranJagtiani

Description

@KaranJagtiani

The k8s_patch tool accepts any string for patch_type and the k8s_get tool accepts any string for output format, but neither validates against the allowed values. Invalid values are passed to kubectl which returns cryptic errors. Other tools like k8s_rollout_undo already validate their enum-like parameters.

Scope

  • MCP (mcp/tools/kubectl.py):
    • k8s_patch: Validate that patch_type is one of "strategic", "merge", or "json". Return a clear error listing the allowed values if an invalid type is provided.
    • k8s_get: Validate that output (when provided) is one of "wide", "yaml", "json", "name". Return a clear error listing the allowed values if an invalid format is provided.
    • Follow the existing pattern from k8s_rollout_undo which validates resource_type against an allowed list.

Acceptance criteria

  • Passing an invalid patch_type (e.g., "invalid") to k8s_patch returns a clear error with the list of valid options.
  • Passing an invalid output format (e.g., "csv") to k8s_get returns a clear error with valid options.
  • Valid values continue to work as expected.
  • Validation follows the existing pattern in the codebase.

How to test manually

  1. Run the Engine and MCP server locally (see engine/README.md and mcp/README.md).
  2. Trigger a k8s_patch call with an invalid patch type and verify a clear error is returned.
  3. Trigger a k8s_get call with a valid output format and verify it works.

Metadata

Metadata

Assignees

Labels

featuregood first issueGood for newcomersmcpTailor-made MCP powering Skyflo.ai

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions