Skip to content

Commit bb6193f

Browse files
feat: add list-tools CLI command proof of concept
1 parent 7c62774 commit bb6193f

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

cmd/github-mcp-server/list_tools.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"sort"
6+
7+
"github.com/github/github-mcp-server/pkg/github"
8+
"github.com/github/github-mcp-server/pkg/translations"
9+
"github.com/spf13/cobra"
10+
"github.com/spf13/viper"
11+
)
12+
13+
var listToolsPocCmd = &cobra.Command{
14+
Use: "list-tools",
15+
Short: "List available MCP tools grouped by toolset",
16+
Long: `Display all registered MCP tools, grouped by toolset.`,
17+
RunE: func(cmd *cobra.Command, args []string) error {
18+
fmt.Println("TODO: Implement list-tools functionality")
19+
fmt.Println("This is a proof of concept for the list-tools command.")
20+
fmt.Println("Would display all available MCP tools grouped by toolset.")
21+
return nil
22+
},
23+
}
24+
25+
func init() {
26+
rootCmd.AddCommand(listToolsPocCmd)
27+
}
28+
29+
// TODO: Add filtering by toolset (e.g., --toolset=repos)
30+
// TODO: Support output formats (e.g., --format=json, yaml, table)
31+
// TODO: Respect active toolsets, dynamic toolsets, and read-only flags
32+
// TODO: Add unit tests once design is confirmed useful
33+
34+
func listTools() error {
35+
// Get configuration from viper
36+
var enabledToolsets []string
37+
if err := viper.UnmarshalKey("toolsets", &enabledToolsets); err != nil {
38+
return fmt.Errorf("failed to unmarshal toolsets: %w", err)
39+
}
40+
41+
readOnly := viper.GetBool("read-only")
42+
43+
// Create translation helper
44+
t, _ := translations.TranslationHelper()
45+
46+
// Create toolset group with mock clients
47+
tsg := github.DefaultToolsetGroup(readOnly, mockGetClient, mockGetGQLClient, mockGetRawClient, t)
48+
49+
// Enable specified toolsets
50+
if err := tsg.EnableToolsets(enabledToolsets); err != nil {
51+
return fmt.Errorf("failed to enable toolsets: %w", err)
52+
}
53+
54+
// Get sorted toolset names
55+
var toolsetNames []string
56+
for name := range tsg.Toolsets {
57+
toolsetNames = append(toolsetNames, name)
58+
}
59+
sort.Strings(toolsetNames)
60+
61+
for _, toolsetName := range toolsetNames {
62+
toolset := tsg.Toolsets[toolsetName]
63+
64+
// Skip if toolset is not enabled
65+
if !toolset.Enabled {
66+
continue
67+
}
68+
69+
fmt.Printf("\nToolset: %s\n", toolsetName)
70+
fmt.Printf("Description: %s\n", toolset.Description)
71+
fmt.Println()
72+
73+
tools := toolset.GetActiveTools()
74+
if len(tools) == 0 {
75+
fmt.Println(" No tools available")
76+
continue
77+
}
78+
79+
// Sort tools by name
80+
sort.Slice(tools, func(i, j int) bool {
81+
return tools[i].Tool.Name < tools[j].Tool.Name
82+
})
83+
84+
for _, serverTool := range tools {
85+
tool := serverTool.Tool
86+
fmt.Printf("- %s: %s\n", tool.Name, tool.Description)
87+
}
88+
fmt.Println()
89+
}
90+
91+
return nil
92+
}

cmd/github-mcp-server/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ var (
5959
return ghmcp.RunStdioServer(stdioServerConfig)
6060
},
6161
}
62+
63+
listToolsCmd = &cobra.Command{
64+
Use: "list-tools",
65+
Short: "List available MCP tools grouped by toolset",
66+
Long: `Display all registered MCP tools, grouped by toolset.`,
67+
RunE: func(cmd *cobra.Command, args []string) error {
68+
fmt.Println("TODO: Implement list-tools functionality")
69+
fmt.Println("This is a proof of concept for the list-tools command.")
70+
fmt.Println("Would display all available MCP tools grouped by toolset.")
71+
return nil
72+
},
73+
}
6274
)
6375

6476
func init() {
@@ -87,6 +99,7 @@ func init() {
8799

88100
// Add subcommands
89101
rootCmd.AddCommand(stdioCmd)
102+
rootCmd.AddCommand(listToolsCmd)
90103
}
91104

92105
func initConfig() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy