Commit Graph

48 Commits

Author SHA1 Message Date
Calum Murray
a2d16e9f41 feat: Multi Cluster Support (#348)
* feat: add cluster provider for kubeconfig

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: move server to use ClusterProvider interface

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: authentication middleware works with cluster provider

Signed-off-by: Calum Murray <cmurray@redhat.com>

* fix: unit tests work after cluster provider changes

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: add tool mutator to add cluster parameter

Signed-off-by: Calum Murray <cmurray@redhat.com>

* test: handle cluster parameter

Signed-off-by: Calum Murray <cmurray@redhat.com>

* fix: handle lazy init correctly

Signed-off-by: Calum Murray <cmurray@redhat.com>

* refactor: move to using multi-strategy ManagerProvider

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: add contexts_list tool

Signed-off-by: Calum Murray <cmurray@redhat.com>

* refactor: make tool mutator generic between cluster/context naming

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: introduce tool filter

Signed-off-by: Calum Murray <cmurray@redhat.com>

* refactor: use new ManagerProvider/mutator/filter within mcp server

Signed-off-by: Calum Murray <cmurray@redhat.com>

* fix(test): tests expect context parameter in tool defs

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: auth handles multi-cluster case correctly

Signed-off-by: Calum Murray <cmurray@redhat.com>

* fix: small changes from local testing

Signed-off-by: Calum Murray <cmurray@redhat.com>

* chore: fix enum test

Signed-off-by: Calum Murray <cmurray@redhat.com>

* review: Multi Cluster support (#1)

* nit: rename contexts_list to configuration_contexts_list

Besides the conventional naming, it helps LLMs understand the context of the tool by providing a certain level of hierarchy.

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* fix(mcp): ToolMutator doesn't rely on magic strings

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* refactor(api): don't expose ManagerProvider to toolsets

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* test(mcp): configuration_contexts_list basic tests

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* test(toolsets): revert edge-case test

This test should not be touched.

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* test(toolsets): add specific metadata tests for multi-cluster

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* fix(mcp): ToolFilter doesn't rely on magic strings (partially)

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* test(api): IsClusterAware and IsTargetListProvider default values

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* test(mcp): revert unneeded changes in mcp_tools_test.go

Signed-off-by: Marc Nuri <marc@marcnuri.com>

---------

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* fix: always include configuration_contexts_list if contexts > 1

Signed-off-by: Calum Murray <cmurray@redhat.com>

* feat: include server urls in configuration_contexts_list

Signed-off-by: Calum Murray <cmurray@redhat.com>

---------

Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Marc Nuri <marc@marcnuri.com>
Co-authored-by: Marc Nuri <marc@marcnuri.com>
2025-10-06 12:01:16 +02:00
Marc Nuri
792d2f5b80 chore(lint): fix linting issues (#344)
* chore(lint): fix linting issues

Signed-off-by: Marc Nuri <marc@marcnuri.com>

* feat(ci): add linting to build and build-all-platforms target

Signed-off-by: Marc Nuri <marc@marcnuri.com>

---------

Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-26 06:56:48 +02:00
Marc Nuri
e16114dfc5 test(mcp): refactor core toolset tests (namespaces) (#330)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-17 15:48:57 +02:00
Marc Nuri
d6936f42d3 test(mcp): refactor events toolset tests (#328)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-17 11:48:35 +02:00
Marc Nuri
d9d35b9834 test(toolsets): toolset specific metadata tests (#326)
- Refactor tests to use testify (more clarity+composability for complex tests)
- Tests for default toolsets
- Tests for configured, granular toolsets

Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-17 11:06:17 +02:00
Marc Nuri
48cf204a89 feat(toolsets): add support for multiple toolsets in configuration (#323)
Users can now enable or disable different toolsets either by providing
a command-line flag or by setting the toolsets array field in the TOML
configuration.

Downstream Kubernetes API developers can declare toolsets for their
APIs by creating a new nested package in pkg/toolsets and registering
it in pkg/mcp/modules.go

Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-17 10:53:56 +02:00
Marc Nuri
209e8434d5 feat(mcp): toolset definitions completely agnostic from underlying MCP impl (#322)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-12 11:56:22 +02:00
Marc Nuri
10c82f7bff refactor(toolsets): renamed Profile to Toolset (#309)
As a prior step to providing support for toolsets
this change repurposes the current work in profiles
which partially aligns with the toolsets expected features

Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-09-11 09:25:09 +02:00
Marc Nuri
0ec2599bd8 fix:test: prevent usage of real cluster in tests (#282)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-08-26 14:52:27 +02:00
Marc Nuri
49dcff3f21 feat(mcp): log tool call (HTTP headers) (#221)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-07-30 15:25:07 +02:00
Marc Nuri
cad863ff22 fix(migration): rebranded from manusa/kubernetes-mcp-server to containers/kubernetes-mcp-server (#202)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-07-25 09:53:04 +02:00
Marc Nuri
ca0aa4648d feat(mcp): log tool call (function name + arguments)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-07-22 14:35:19 +02:00
Marc Nuri
3fbfd8d7cb fix(lint): add golangci-lint make target + lint
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-07-22 14:22:19 +02:00
Marc Nuri
cb9f296566 test(mcp): speed up tests by not setting the fake kubeconfig master to example.com
Signed-off-by: Marc Nuri <marc@marcnuri.com>
2025-07-18 10:46:32 +02:00
Arda Güçlü
186f445ca2 feat(config): introduce enabled/disabled tool list in configuration file (155)
Introduce allow/deny tool functionality in toml config
---
Remove duplicate fields that already defined in staticConfig
---
Add unit tests to verify tool valid check
---
Wire staticConfig to fix unit tests
---
Rename to enabled/disabled instead of allowed/denied
2025-07-01 16:02:36 +02:00
Marc Nuri
1968652aca test(config): extensive test suite for denied lists 2025-06-23 13:09:02 +02:00
Arda Güçlü
754da19d81 feat(config): introduce toml configuration file with a set of deny list 2025-06-19 13:41:47 +02:00
Marc Nuri
7e10e82a3a feat(output): table output to minimize resource list verbosity
A new configuration options is available: `--list-output`

There are two modes available:
 - `yaml`: current default (will be changed in subsequent PR), which returns a multi-document YAML
 - `table`: returns a plain-text table as created by the kube-api server when requested with
   `Accept: application/json;as=Table;v=v1;g=meta.k8s.io`

Additional logic has been added to the table format to include the apiVersion and kind.
This is not returned by the server, kubectl doesn't include this either.
However, this is extremely handy for the LLM when using the generic resource tools.
2025-06-12 13:26:40 +02:00
Marc Nuri
155fe6847f feat(output): configurable output architecture 2025-06-11 12:13:23 +02:00
Marc Nuri
f80d8df3c4 feat(auth): authorize user from custom SSE header (96)
feat(auth): Authorize user from custom SSE header

PoC to show how we can propagate an Authorization Bearer token
from the MCP client up to the Kubernetes API by passing a custom
header (Kubernetes-Authorization-Bearer-Token).

A new Derived client is necessary for each request due to the incompleteness
of some of the client-go clients.
This might add some overhead for each prompt.
Ideally, the issue with the discoveryclient and others should be fixed to
allow reading the authorization header from the request context.

To use the feature, the MCP Server still needs to be started with a basic
configuration (either provided InCluster by a service account or locally by
 a .kube/config file) so that it's able to infer the server settings.
---
test(auth): added tests to verify header propagation
---
refactor(auth): minor improvements for derived client
2025-05-29 17:07:28 +02:00
Marc Nuri
e6f20fc777 feat(config): --disable-destructive exposes tools not annotated with destructiveHint=true 2025-05-26 18:36:45 +02:00
Marc Nuri
5f279a81d8 feat(config): --read-only mode flag exposes only read-only annotated tools 2025-05-26 16:13:36 +02:00
Eran Cohen
2994699504 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>
2025-05-20 16:34:53 +02:00
Marc Nuri
e0fe25af3c test: add concurrency to OpenShift env setup 2025-05-16 13:14:22 +02:00
Marc Nuri
20cb33130a test: openshift environment using hooks 2025-05-16 11:49:55 +02:00
Marc Nuri
1f00601f43 test(profiles): bootstrap initial testing support for profiles 2025-05-16 11:30:14 +02:00
Marc Nuri
1f22f5b23f feat(profiles): bootstrap initial support for profiles 2025-05-15 16:55:08 +02:00
Marc Nuri
fa5bb81fe5 feat(kubernetes): added --kubeconfig flag option 2025-04-19 10:01:41 +02:00
Marc Nuri
79b0f2805c build(deps): bump github.com/mark3labs/mcp-go from 0.20.1 to 0.21.0 2025-04-17 07:21:25 +02:00
Marc Nuri
72ede2ea10 test: wait for CRD deletion 2025-03-27 19:03:54 +01:00
Marc Nuri
d74398f85b feat: support for listing namespaces and OpenShift projects 2025-03-27 16:50:13 +01:00
Marc Nuri
50277ce954 feat: configuration minification is optional 2025-03-27 06:50:14 +01:00
Marc Nuri
a98e69102c feat: watch for configuration changes
Watch kube config files for changes.
Automatically reload kubernetes client and list of tools.

Useful for logins or context changes after an MCP session has started.
2025-03-21 18:05:41 +01:00
Marc Nuri
39d21d77b0 test:fix: delete CRDs immediately 2025-03-07 13:14:19 +01:00
Marc Nuri
d7075f2c78 feat: improved prompt efficiency for OpenShift resources 2025-03-07 11:56:57 +01:00
Marc Nuri
7b129281f4 deps: bump github.com/mark3labs/mcp-go from v0.8.5 to v0.11.2 2025-03-07 09:44:02 +01:00
Marc Nuri
3522e4fb44 feat(kubernetes): fallback to configured namespace when listing from all namespaces
Fixes #4

If user is not authorized to list from all namespaces try to list from the configured namespace only.
2025-02-20 16:52:16 +01:00
Marc Nuri
90c2802429 fix(test): reset kube config location for each test 2025-02-20 07:06:00 +01:00
Marc Nuri
d3754585ec feat(kubernetes): reusable Kubernetes clients
Improve cache performance
2025-02-20 06:33:42 +01:00
Marc Nuri
40ff50e04d feat(kubernetes): pods_delete deletes managed resources 2025-02-19 16:20:50 +01:00
Marc Nuri
e6ab757915 feat(kubernetes): pods_run creates OpenShift routes 2025-02-18 05:34:27 +01:00
Marc Nuri
a8bb7c01a7 feat(kubernetes): resources_delete can get any resource in the cluster 2025-02-17 13:17:48 +01:00
Marc Nuri
6ae9247bae feat(kubernetes): resources_create_or_update can create or update any kind of resource 2025-02-17 12:05:59 +01:00
Marc Nuri
f591e2b06b feat(kubernetes): pods_get for explicit or nil namespace 2025-02-17 08:52:22 +01:00
Marc Nuri
0f12797365 test(pods): pods_list_in_namespace test suite 2025-02-17 06:38:44 +01:00
Marc Nuri
9ad87d362d feat(kubernetes): marshal all resources to yaml omitting managed fields 2025-02-15 04:59:00 +01:00
Marc Nuri
80488ef6ee feat(resources): initial support for resource listing 2025-02-13 16:06:06 +01:00
Marc Nuri
590f47c779 feat(configuration): initial configuration_view view implementation 2025-02-13 05:59:14 +01:00