feat: add label selectors to listing tools

This PR introduces the ability to filter Kubernetes resources by label using a labelSelector parameter for the following tools:

 * pods_list
 * pods_list_in_namespace
 * resources_list

This enhancement allows users to retrieve a more specific set of resources based on their labels, improving the flexibility and utility of these tools.

The labelSelector parameter accepts standard Kubernetes label selector syntax, such as app=myapp,env=prod or app in (myapp,yourapp).

Signed-off-by: Eran Cohen <eranco@redhat.com>
This commit is contained in:
Eran Cohen
2025-05-20 17:34:53 +03:00
committed by GitHub
parent ba2b072942
commit 2994699504
9 changed files with 292 additions and 49 deletions

View File

@@ -261,7 +261,9 @@ Get a Kubernetes Pod in the current or provided namespace with the provided name
List all the Kubernetes pods in the current cluster from all namespaces
**Parameters:** None
**Parameters:**
- `labelSelector` (`string`, optional)
- Kubernetes label selector (e.g., 'app=myapp,env=prod' or 'app in (myapp,yourapp)'). Use this option to filter the pods by label
### `pods_list_in_namespace`
@@ -270,6 +272,8 @@ List all the Kubernetes pods in the specified namespace in the current cluster
**Parameters:**
- `namespace` (`string`, required)
- Namespace to list pods from
- `labelSelector` (`string`, optional)
- Kubernetes label selector (e.g., 'app=myapp,env=prod' or 'app in (myapp,yourapp)'). Use this option to filter the pods by label
### `pods_log`
@@ -363,6 +367,8 @@ List Kubernetes resources and objects in the current cluster
- Namespace to retrieve the namespaced resources from
- Ignored for cluster-scoped resources
- Lists resources from all namespaces if not provided
- `labelSelector` (`string`, optional)
- Kubernetes label selector (e.g., 'app=myapp,env=prod' or 'app in (myapp,yourapp)'). Use this option to filter the pods by label.
## 🧑‍💻 Development <a id="development"></a>