Skip to content

Commit 144ec22

Browse files
authored
Add plugins config command (#213)
Implements parent command structure for 'mcpd config plugins' that will support managing plugin configuration including plugin entries and plugin-level settings.
1 parent 3728192 commit 144ec22

File tree

10 files changed

+264
-5
lines changed

10 files changed

+264
-5
lines changed

cmd/config/config.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/mozilla-ai/mcpd/v2/cmd/config/daemon"
88
"github.com/mozilla-ai/mcpd/v2/cmd/config/env"
99
"github.com/mozilla-ai/mcpd/v2/cmd/config/export"
10+
"github.com/mozilla-ai/mcpd/v2/cmd/config/plugins"
1011
"github.com/mozilla-ai/mcpd/v2/cmd/config/tools"
1112
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
1213
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
@@ -21,11 +22,12 @@ func NewConfigCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Comman
2122

2223
// Sub-commands for: mcpd config
2324
fns := []func(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error){
24-
args.NewCmd, // args
25-
daemon.NewCmd, // daemon
26-
env.NewCmd, // env
27-
tools.NewCmd, // tools
28-
export.NewCmd, // export
25+
args.NewCmd, // args
26+
daemon.NewCmd, // daemon
27+
env.NewCmd, // env
28+
plugins.NewCmd, // plugins
29+
tools.NewCmd, // tools
30+
export.NewCmd, // export
2931
}
3032

3133
for _, fn := range fns {

cmd/config/plugins/add.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewAddCmd creates the add command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewAddCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "add",
17+
Short: "Add a new plugin entry to a category",
18+
Long: "Add a new plugin entry to a category. The configuration is saved automatically.",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

cmd/config/plugins/cmd.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package plugins
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
7+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
8+
)
9+
10+
// NewCmd creates the parent plugins command.
11+
func NewCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
12+
cobraCmd := &cobra.Command{
13+
Use: "plugins",
14+
Short: "Manage plugin configuration",
15+
Long: "Manage plugin configuration including plugin entries (authentication, observability, etc.) " +
16+
"and plugin-level settings (directory path, etc.)",
17+
}
18+
19+
// Sub-commands for: mcpd config plugins.
20+
fns := []func(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error){
21+
NewAddCmd, // add
22+
NewGetCmd, // get
23+
NewListCmd, // list
24+
NewMoveCmd, // move
25+
NewRemoveCmd, // remove
26+
NewSetCmd, // set
27+
NewValidateCmd, // validate
28+
}
29+
30+
for _, fn := range fns {
31+
tempCmd, err := fn(baseCmd, opt...)
32+
if err != nil {
33+
return nil, err
34+
}
35+
cobraCmd.AddCommand(tempCmd)
36+
}
37+
38+
return cobraCmd, nil
39+
}

cmd/config/plugins/cmd_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package plugins_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
8+
"github.com/mozilla-ai/mcpd/v2/cmd/config/plugins"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
10+
)
11+
12+
func TestPlugins_NewCmd_Success(t *testing.T) {
13+
t.Parallel()
14+
15+
baseCmd := &cmd.BaseCmd{}
16+
cobraCmd, err := plugins.NewCmd(baseCmd)
17+
18+
require.NoError(t, err)
19+
require.NotNil(t, cobraCmd)
20+
require.Equal(t, "plugins", cobraCmd.Use)
21+
22+
// Verify all subcommands are registered.
23+
commands := cobraCmd.Commands()
24+
require.Len(t, commands, 7)
25+
26+
// Verify expected subcommands are present (Cobra sorts alphabetically).
27+
expectedCmds := map[string]bool{
28+
"add": true,
29+
"get": true,
30+
"list": true,
31+
"move": true,
32+
"remove": true,
33+
"set": true,
34+
"validate": true,
35+
}
36+
37+
for _, command := range commands {
38+
require.True(t, expectedCmds[command.Use], "unexpected command: %s", command.Use)
39+
delete(expectedCmds, command.Use)
40+
}
41+
42+
require.Empty(t, expectedCmds, "missing expected commands")
43+
}

cmd/config/plugins/get.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewGetCmd creates the get command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewGetCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "get",
17+
Short: "Get plugin-level config or specific plugin entry",
18+
Long: "Get plugin-level configuration (when no flags provided) or specific plugin entry (when --category and --name provided)",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

cmd/config/plugins/list.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewListCmd creates the list command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewListCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "list",
17+
Short: "List plugin entries",
18+
Long: "List plugin entries in a specific category or across all categories",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

cmd/config/plugins/move.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewMoveCmd creates the move command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewMoveCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "move",
17+
Short: "Reorder a plugin entry within its category",
18+
Long: "Reorder a plugin entry within its category. Plugin execution order matters.",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

cmd/config/plugins/remove.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewRemoveCmd creates the remove command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewRemoveCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "remove",
17+
Short: "Remove a plugin entry from a category",
18+
Long: "Remove a plugin entry from a category. The configuration is saved automatically.",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

cmd/config/plugins/set.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewSetCmd creates the set command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewSetCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "set",
17+
Short: "Set plugin-level config or plugin entry",
18+
Long: "Set plugin-level configuration (--dir) or create/update a plugin entry (--category, --name, --flows)",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

cmd/config/plugins/validate.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugins
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
8+
"github.com/mozilla-ai/mcpd/v2/internal/cmd"
9+
"github.com/mozilla-ai/mcpd/v2/internal/cmd/options"
10+
)
11+
12+
// NewValidateCmd creates the validate command for plugins.
13+
// TODO: Implement in a future PR.
14+
func NewValidateCmd(baseCmd *cmd.BaseCmd, opt ...options.CmdOption) (*cobra.Command, error) {
15+
cobraCmd := &cobra.Command{
16+
Use: "validate",
17+
Short: "Validate plugin configuration",
18+
Long: "Validate plugin configuration structure (portable) and optionally check plugin binaries (environment-specific)",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
return fmt.Errorf("not yet implemented")
21+
},
22+
}
23+
24+
return cobraCmd, nil
25+
}

0 commit comments

Comments
 (0)