Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add placeholder list-tools CLI command (PoC)#618

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
salignatmoandal wants to merge1 commit intogithub:main
base:main
Choose a base branch
Loading
fromsalignatmoandal:feat/list-tools
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletionscmd/github-mcp-server/list_tools.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
package main

import (
"fmt"
"sort"

"github.com/github/github-mcp-server/pkg/github"
"github.com/github/github-mcp-server/pkg/translations"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var listToolsPocCmd = &cobra.Command{
Use: "list-tools",
Short: "List available MCP tools grouped by toolset",
Long: `Display all registered MCP tools, grouped by toolset.`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("TODO: Implement list-tools functionality")
fmt.Println("This is a proof of concept for the list-tools command.")
fmt.Println("Would display all available MCP tools grouped by toolset.")
return nil
},
}

func init() {
rootCmd.AddCommand(listToolsPocCmd)
}

// TODO: Add filtering by toolset (e.g., --toolset=repos)
// TODO: Support output formats (e.g., --format=json, yaml, table)
// TODO: Respect active toolsets, dynamic toolsets, and read-only flags
// TODO: Add unit tests once design is confirmed useful

func listTools() error {
// Get configuration from viper
var enabledToolsets []string
if err := viper.UnmarshalKey("toolsets", &enabledToolsets); err != nil {
return fmt.Errorf("failed to unmarshal toolsets: %w", err)
}

readOnly := viper.GetBool("read-only")

// Create translation helper
t, _ := translations.TranslationHelper()

// Create toolset group with mock clients
tsg := github.DefaultToolsetGroup(readOnly, mockGetClient, mockGetGQLClient, mockGetRawClient, t)

// Enable specified toolsets
if err := tsg.EnableToolsets(enabledToolsets); err != nil {
return fmt.Errorf("failed to enable toolsets: %w", err)
}

// Get sorted toolset names
var toolsetNames []string
for name := range tsg.Toolsets {
toolsetNames = append(toolsetNames, name)
}
sort.Strings(toolsetNames)

for _, toolsetName := range toolsetNames {
toolset := tsg.Toolsets[toolsetName]

// Skip if toolset is not enabled
if !toolset.Enabled {
continue
}

fmt.Printf("\nToolset: %s\n", toolsetName)
fmt.Printf("Description: %s\n", toolset.Description)
fmt.Println()

tools := toolset.GetActiveTools()
if len(tools) == 0 {
fmt.Println(" No tools available")
continue
}

// Sort tools by name
sort.Slice(tools, func(i, j int) bool {
return tools[i].Tool.Name < tools[j].Tool.Name
})

for _, serverTool := range tools {
tool := serverTool.Tool
fmt.Printf("- %s: %s\n", tool.Name, tool.Description)
}
fmt.Println()
}

return nil
}
13 changes: 13 additions & 0 deletionscmd/github-mcp-server/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,18 @@ var (
return ghmcp.RunStdioServer(stdioServerConfig)
},
}

listToolsCmd = &cobra.Command{
Use: "list-tools",
Short: "List available MCP tools grouped by toolset",
Long: `Display all registered MCP tools, grouped by toolset.`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("TODO: Implement list-tools functionality")
fmt.Println("This is a proof of concept for the list-tools command.")
fmt.Println("Would display all available MCP tools grouped by toolset.")
return nil
},
}
)

func init() {
Expand DownExpand Up@@ -87,6 +99,7 @@ func init() {

// Add subcommands
rootCmd.AddCommand(stdioCmd)
rootCmd.AddCommand(listToolsCmd)
}

func initConfig() {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp