Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #9

Merged
merged 2 commits into from
Dec 26, 2024
Merged

Add Dockerfile #9

merged 2 commits into from
Dec 26, 2024

Conversation

mikesir87
Copy link
Contributor

Hey there! Thanks for the fun MCP server! This PR adds a Dockerfile to allow the project to be built and distributed as a container image (following after modelcontextprotocol/servers#368).

A blog post and more is to come soon about containerized MCP servers, so stay tuned! 😄

@Flux159
Copy link
Owner

Flux159 commented Dec 26, 2024

I don't think this container will work properly right now because the user won't have their kubernetes config inside of the docker container. Right now it's using the default kubeconfig: https://github.com/Flux159/mcp-server-kubernetes/blob/main/src/index.ts#L30 (generally at $HOME/.kube directory) - not having that inside of the container or binding that directory to a volume inside of the container will most likely not work properly.

@mikesir87
Copy link
Contributor Author

Great comment! I did test it by mounting my config directory into the container and it worked as I expected. But yeah... we might want to add an example on what the container config looks like.

And to loop back... the blog post about Docker and Anthropic working together to support containerized MCP servers can be found here - https://www.docker.com/blog/the-model-context-protocol-simplifying-building-ai-apps-with-anthropic-claude-desktop-and-docker/

@Flux159
Copy link
Owner

Flux159 commented Dec 26, 2024

I did test it by mounting my config directory into the container and it worked as I expected. But yeah... we might want to add an example on what the container config looks like.

Ah makes sense - yeah adding that to the README would be great. It can be a separate commit / PR though & this can just add the Dockerfile. LGTM.

@Flux159 Flux159 merged commit 2d42893 into Flux159:main Dec 26, 2024
@Flux159
Copy link
Owner

Flux159 commented Jan 1, 2025

Just a followup here, I published flux159/mcp-server-kubernetes to dockerhub.

I haven't had the chance to test it out, but I assume that it would be loaded into Claude desktop with something like this, specifically you would need to mount your kube credentials into the docker container by mounting your $HOME/.kube directory.:

{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": ["run", "flux159/mcp-server-kubernetes", "-v", "~/.kube:/.kube"]
    }
  }
}

Will update readme after I get the chance to test it out (may take a bit since I'm working on other things) or if someone else can validate & update the README in a PR.

Note that I'm not sure if "/.kube" is the right place to mount inside of the container right now @mikesir87 - can you confirm what directory worked for you?

@slimslenderslacks
Copy link

There's an argument ordering issue above:

{
  "mcpServers": {
    "kubernetes": {
      "command": "docker",
      "args": ["run", "-v", "~/.kube:/.kube", "flux159/mcp-server-kubernetes"]
    }
  }
}

We've also been discussing how an mcp client should negotiate and get consent for the server to access a local directory like ~/.kube. I haven't verified but I think the home directory of appuser will actually be / since nothing was explicitly specified in that useradd command.

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.

3 participants