Skip to content

feat: add dapr mcpservers cli cmd#1628

Open
sicoyle wants to merge 1 commit intodapr:masterfrom
sicoyle:feat/mcp-crd
Open

feat: add dapr mcpservers cli cmd#1628
sicoyle wants to merge 1 commit intodapr:masterfrom
sicoyle:feat/mcp-crd

Conversation

@sicoyle
Copy link
Copy Markdown
Contributor

@sicoyle sicoyle commented Apr 9, 2026

Description

Summary

  • Adds dapr mcpservers -k command to list MCPServer CRD resources in Kubernetes
  • Supports --name, --namespace, --all-namespaces, and -o json/yaml flags
  • Follows the same pattern as dapr components -k and dapr configurations -k

This will fail until my upstream PR here is merged with the clientset changes required for this:
dapr/dapr#9742

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Samantha Coyle <sam@diagrid.io>
@sicoyle sicoyle requested review from a team as code owners April 9, 2026 19:42
Copilot AI review requested due to automatic review settings April 9, 2026 19:42
@sicoyle sicoyle mentioned this pull request Apr 9, 2026
3 tasks
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Kubernetes-mode CLI command (dapr mcpservers -k) to list Dapr MCPServer CRD resources, aligning output/flags with existing components and configurations listing patterns.

Changes:

  • Introduces Kubernetes client helpers to list/print MCPServer resources with table and JSON/YAML output.
  • Adds a new dapr mcpservers Cobra command with --name, --namespace, --all-namespaces, and -o flags.
  • Adds unit tests for listing/filtering behavior and endpoint-derived fields (transport/URL).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/kubernetes/mcpservers.go Implements listing, filtering, table output, and JSON/YAML detail output for MCPServers.
pkg/kubernetes/mcpservers_test.go Adds tests for write path, transport detection, and URL derivation.
cmd/mcpservers.go Adds the new dapr mcpservers CLI command and flags wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +46
Name string `json:"name"`
Namespace string `json:"namespace"`
Spec v1alpha1.MCPServerSpec `json:"spec"`
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

For consistency with other *DetailedOutput structs used by utils.PrintDetail (e.g., configurationDetailedOutput), include yaml tags alongside json tags here so YAML output is guaranteed to have the intended field names regardless of the YAML marshaller implementation.

Suggested change
Name string `json:"name"`
Namespace string `json:"namespace"`
Spec v1alpha1.MCPServerSpec `json:"spec"`
Name string `json:"name" yaml:"name"`
Namespace string `json:"namespace" yaml:"namespace"`
Spec v1alpha1.MCPServerSpec `json:"spec" yaml:"spec"`

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +74
// ListMCPServers lists MCPServer resources from Kubernetes.
func ListMCPServers(client versioned.Interface, namespace string) (*v1alpha1.MCPServerList, error) {
list, err := client.MCPServerV1alpha1().MCPServers(namespace).List(meta_v1.ListOptions{})
// This means that the Dapr MCPServer CRD is not installed and
// therefore no MCPServer items exist.
if apierrors.IsNotFound(err) {
list = &v1alpha1.MCPServerList{
Items: []v1alpha1.MCPServer{},
}
} else if err != nil {
return nil, err
}

return list, nil
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This introduces a dependency on the MCPServer typed client (client.MCPServerV1alpha1()), but this repo’s current github.com/dapr/dapr module version may not include the generated clientset for MCPServer yet (as noted in the PR description). Please update go.mod (or add a temporary replace) to a dapr/dapr commit that contains the MCPServer clientset changes, otherwise this will not compile in CI.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +37
testCases := []struct {
name string
serverName string
outputFormat string
errorExpected bool
errString string
mcpServers []v1alpha1.MCPServer
expectedOutput string
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The test case struct includes errString, but the test always returns assert.AnError and never asserts the error message. Either remove errString entirely or return errors.New(tc.errString) and assert err.Error() matches, so the intent of the test is reflected in the assertions.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +34
var McpserversCmd = &cobra.Command{
Use: "mcpservers",
Short: "List all Dapr MCPServer resources. Supported platforms: Kubernetes",
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Go naming for initialisms typically keeps them fully-capitalized (e.g., MTLSCmd). Consider renaming McpserversCmd to MCPServersCmd (and file-local references accordingly) to match the established command naming style.

Copilot uses AI. Check for mistakes.
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.

2 participants