Skip to content

Conversation

@Cali0707
Copy link
Collaborator

@Cali0707 Cali0707 commented Sep 26, 2025

Fixes #83
Supersedes closes #325

This PR builds on the approach taken in #325, but makes it more generic so that we can configure how clients select the cluster based on the cluster provider strategy (currently supporting in-cluster and kubeconfig).

There is a contexts_list tool added as well, which is conditionally enabled when there are more than 15 contexts in the kubeconfig, as that is when we switch from using an enum parameter to a general string parameter.

@Cali0707
Copy link
Collaborator Author

So far, this PR only adds the ClusterProvider interface and the implementation for a kubeconfig provider.

The idea is that the provider can be used to get a Manager instance for the cluster requested in the tool provider.

Barring any feedback against this approach, I will continue with adding the cluster parameter to tools whenever the number of clusters is > 1, and using the provider interface to get the correct manager to each tool.

@Cali0707

This comment was marked as resolved.

@Cali0707 Cali0707 marked this pull request as ready for review October 1, 2025 18:17
@Cali0707 Cali0707 changed the title [WIP] Multi Cluster Support feat: Multi Cluster Support Oct 1, 2025
@Cali0707
Copy link
Collaborator Author

Cali0707 commented Oct 1, 2025

@manusa I tried to keep the changes separated out by commit to make reviewing easier, let me know if I should squash them

@manusa
Copy link
Member

manusa commented Oct 2, 2025

It's looking good, let me review it locally and propose some changes (if applicable) as a PR to your branch.

@manusa manusa self-assigned this Oct 3, 2025
@manusa
Copy link
Member

manusa commented Oct 3, 2025

I'm adding a few changes to the branch and restructuring a bit. I'll try to have a PR to your branch ready later today.

@manusa
Copy link
Member

manusa commented Oct 3, 2025

We can squash everything together once the feature is ready.

Signed-off-by: Calum Murray <[email protected]>
@manusa
Copy link
Member

manusa commented Oct 3, 2025

Hui, note I'm working on this: https://github.com/Cali0707/kubernetes-mcp-server/compare/multi-cluster-auth-config...marcnuri-forks:kubernetes-mcp-server:review/mutli-cluster-config?expand=1
I'll send a PR very soon.

@Cali0707
Copy link
Collaborator Author

Cali0707 commented Oct 3, 2025

Thanks @manusa !

* 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 <[email protected]>

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

Signed-off-by: Marc Nuri <[email protected]>

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

Signed-off-by: Marc Nuri <[email protected]>

* test(mcp): configuration_contexts_list basic tests

Signed-off-by: Marc Nuri <[email protected]>

* test(toolsets): revert edge-case test

This test should not be touched.

Signed-off-by: Marc Nuri <[email protected]>

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

Signed-off-by: Marc Nuri <[email protected]>

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

Signed-off-by: Marc Nuri <[email protected]>

* test(api): IsClusterAware and IsTargetListProvider default values

Signed-off-by: Marc Nuri <[email protected]>

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

Signed-off-by: Marc Nuri <[email protected]>

---------

Signed-off-by: Marc Nuri <[email protected]>
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM, thx!

Originally posted in Cali0707#1

The tool mutator is a great way to tackle the multi-cluster problem with minimal impact on the toolsets 🙌

The Kubernetes module architecture is now quite complex, Provider->Manager->Kubernetes.
We might look into merging Provider and Manager together in the future.

The InOpenShift function is making less sense now, especially under the new multi-cluster scenario where some clusters might be openshift while others not.
We should plan for removal. This should also simplify the GetTools-related logic.

In the auth section, I'm not convinced about the changes to KubernetesApiTokenVerifier.
However, this will likely be removed. In the token exchange scenario this wasn't relevant any more.

The output for the configuration_contexts_list tool should be changed to something LLM friendlier and maybe parseable.

I'll probably add some follow-up tasks based on how we agree to proceed.

@manusa
Copy link
Member

manusa commented Oct 3, 2025

@alexeykazakov would you mind giving a look and see if this would work for your current use-case? 🙏

@manusa manusa added this to the 0.1.0 milestone Oct 3, 2025
@manusa manusa removed their assignment Oct 3, 2025
Copy link

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

I tested the PR. Works great!
The readme needs to be updated though.

@sabre1041
Copy link
Contributor

@Cali0707 @manusa Latest enhancements work great! Only comment is what @alexeykazakov already mentioned related to the documentation

@manusa
Copy link
Member

manusa commented Oct 6, 2025

I'll merge now since the PR is quite complex as it is

The readme needs to be updated though.

To be updated in a follow-up. Also maybe add an opt-out option for multi-cluster before cutting the release.

@manusa manusa merged commit a2d16e9 into containers:main Oct 6, 2025
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.

Support for multiple contexts and switching between them

4 participants