Skip to content

Add MCP support for Redpanda Cloud #25802

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Add MCP support for Redpanda Cloud #25802

wants to merge 1 commit into from

Conversation

birdayz
Copy link
Contributor

@birdayz birdayz commented Apr 14, 2025

I would like to avoid introducing a plugin for this for now, we'll be fine with the release cycle of core. We're not expecting this to change very often (and want to spare all the time required to do a plugin).

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v25.1.x
  • v24.3.x
  • v24.2.x
  • v24.1.x

Release Notes

@CLAassistant
Copy link

CLAassistant commented Apr 14, 2025

CLA assistant check
All committers have signed the CLA.

@birdayz birdayz changed the title wip WIP - MCP support Apr 16, 2025
@birdayz birdayz force-pushed the jb/wip-mcp branch 3 times, most recently from a2aa6a8 to b3f3616 Compare April 17, 2025 12:00
@birdayz birdayz marked this pull request as ready for review April 17, 2025 12:00
@birdayz birdayz requested review from r-vasquez, kbatuigas and a team as code owners April 17, 2025 12:00
@@ -41,6 +42,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_model v0.6.1
github.com/prometheus/common v0.62.0
github.com/redpanda-data/common-go/proto v0.0.0-20250416183016-0cd4089182bd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to pull *pb.mcp.go files

this is currently on a branch, i will update before merging

Organization iamv1connect.OrganizationServiceClient
ResourceGroup controlplanev1connect.ResourceGroupServiceClient
Serverless controlplanev1connect.ServerlessClusterServiceClient
Region controlplanev1connect.RegionServiceClient
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added missing clients

@@ -33,6 +33,15 @@ func newAuthInterceptor(token string) connect.UnaryInterceptorFunc {
}
}

func newReloadingAuthInterceptor(f func() string) connect.UnaryInterceptorFunc {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is a specialized interceptor, that does not use a static token. instead, it can call a function that provides the token (which can be refreshed in the background)

@birdayz birdayz changed the title WIP - MCP support Add MCP support for Redpanda Cloud Apr 17, 2025
@birdayz birdayz force-pushed the jb/wip-mcp branch 3 times, most recently from 8022cf2 to 875fa5d Compare April 17, 2025 14:52
Comment on lines +42 to +43
Use: "install [claude]",
Short: "Install Redpanda Cloud MCP server. Only Claude Desktop is supported at this time.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use: "install [claude]",
Short: "Install Redpanda Cloud MCP server. Only Claude Desktop is supported at this time.",
Use: "install [MCP-SERVER]",
Short: "Install Redpanda Cloud MCP server",
Long: `Install Redpanda Cloud MCP server.
Only Claude Desktop is supported at this time.`

And if you can, more documentation on what this command does, i.e: sets a configuration file in the user configuration directory, etc...

cfg, err := p.Load(fs)
out.MaybeDie(err, "Failed to load rpk config: %w", err)

if args[0] != "claude" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make this a flag so it's easier to change in the future. --server or something similar. Managing conflicting args is trickier in the long run.

You could also make the flag required by default (example) and add a autocomplete with the current valid servers (example)

out.DieString("Argument claude is missing")
}
configDir, err := os.UserConfigDir()
out.MaybeDie(err, "failed to load file: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit]

Suggested change
out.MaybeDie(err, "failed to load file: %w", err)
out.MaybeDie(err, "failed to get user configuration directory: %w", err)

Comment on lines +87 to +94
jsonStr, err = sjson.Set(jsonStr, "mcpServers.redpandaCloud.env", map[string]any{
"RPK_CLOUD_URL": "https://cloud-api.ign.cloud.redpanda.com",
"RPK_CLOUD_AUTH_URL": "https://integration-cloudv2.us.auth0.com",
"RPK_CLOUD_AUTH_AUDIENCE": "cloudv2-ign.redpanda.cloud",
"CLOUD_URL": "https://cloud-api.ign.cloud.redpanda.com/api/v1",
"RPK_AUTH_APP_CLIENT_ID": "OQJLrKFCXuCMfGfMfnIqzgiwiyDfoxEV",
"RPK_PUBLIC_API_URL": "https://api.ign.cloud.redpanda.com",
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the new RPK_CLOUD_ENVIRONMENT=integration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how can i programmatically access the -X cloud_environment flag?

Copy link
Contributor

Choose a reason for hiding this comment

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

It gets added on load to the profile https://github.com/redpanda-data/redpanda/blob/dev/src/go/rpk/pkg/config/rpk_yaml.go#L148

It was not intended to be documented nor part of the dev overrides as we didn't see a use for it, but feel free to explore if this suits you or if we need to make a change.

out.MaybeDie(err, "failed to patch Claude Desktop config: %v", err)

// Set dev overrides
if cfg.DevOverrides().PublicAPIURL != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

[question] Why do we set explicitly integration if the PublicAPIURL != "" ? what if it's preprod?

Shouldn't it be

RPK_CLOUD_URL = cfg.DevOverrides().CloudAPIURL

And so on ... ?

That's if RPK_CLOUD_ENVIRONMENT is not enough though.

Use: "stdio",
Short: `MCP stdio server. Can be used by MCP clients.`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {

},
}

cmd.Flags().BoolVarP(&allowDelete, "allow-delete", "", false, "Allow delete RPCs. Off by default.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cmd.Flags().BoolVarP(&allowDelete, "allow-delete", "", false, "Allow delete RPCs. Off by default.")
cmd.Flags().BoolVarP(&allowDelete, "allow-delete", "", false, "Allow delete RPCs. Off by default")

We don't add a period in the flag help text (sorry, we don't have a linter for this yet).

@r-vasquez
Copy link
Contributor

There seem to be missing files for the bazel build, @birdayz please run make bazel to autogenerate the files.

(It's worth rebasing if you are using a Mac as we fixed a bug for the autogeneration in #25368)

@rockwotj rockwotj self-requested a review April 17, 2025 16:37
- Add command to install the MCP server. Currently, only claude desktop
  is supported.
- Add command to serve the stdio server. MCP clients launch it as a
  subprocess, and interact over stdin/stdout with it.
- Authentication to cloud is completely re-used from rpk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants