Skip to content

Commit 7f0fa51

Browse files
make it more awesome
1 parent 6ecee2f commit 7f0fa51

File tree

4 files changed

+35
-446
lines changed

4 files changed

+35
-446
lines changed

pkg/github/dynamic_tools.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func ToolsetEnum(toolsetGroup *toolsets.ToolsetGroup) mcp.PropertyOption {
2121

2222
func EnableToolset(s *server.MCPServer, toolsetGroup *toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
2323
return mcp.NewTool("enable_toolset",
24-
mcp.WithDescription(t("TOOL_ENABLE_TOOLSET_DESCRIPTION", "Enable one of the sets of tools the GitHub MCP server provides, to access the tools and accomplish your goals")),
24+
mcp.WithDescription(t("TOOL_ENABLE_TOOLSET_DESCRIPTION", "Enable one of the sets of tools the GitHub MCP server provides, use get_toolset_tools and list_available_toolsets first to see what this will enable")),
2525
mcp.WithString("toolset",
2626
mcp.Required(),
2727
mcp.Description("The name of the toolset to enable"),
@@ -56,16 +56,26 @@ func EnableToolset(s *server.MCPServer, toolsetGroup *toolsets.ToolsetGroup, t t
5656

5757
func ListAvailableToolsets(toolsetGroup *toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
5858
return mcp.NewTool("list_available_toolsets",
59-
mcp.WithDescription(t("TOOL_LIST_AVAILABLE_FEATURES_DESCRIPTION", "List all available toolsets this GitHub MCP server can offer, providing the enabled status of each. Use this when you think a task could be achieved with a GitHub product, but you don't think the currently available tools could achieve it")),
59+
mcp.WithDescription(t("TOOL_LIST_AVAILABLE_FEATURES_DESCRIPTION", "List all available toolsets this GitHub MCP server can offer, providing the enabled status of each. Use this when a task could be achieved with a GitHub tool and the currently available tools aren't enough. Call get_toolset_tools with these toolset names to discover specific tools you can call")),
6060
),
6161
func(_ context.Context, _ mcp.CallToolRequest) (*mcp.CallToolResult, error) {
6262
// We need to convert the toolsetGroup back to a map for JSON serialization
63-
featureMap := make(map[string]bool)
64-
for name := range toolsetGroup.Toolsets {
65-
featureMap[name] = toolsetGroup.IsEnabled(name)
63+
64+
payload := []map[string]string{}
65+
66+
for name, ts := range toolsetGroup.Toolsets {
67+
{
68+
t := map[string]string{
69+
"name": name,
70+
"description": ts.Description,
71+
"can_enable": "true",
72+
"currently_enabled": fmt.Sprintf("%t", ts.Enabled),
73+
}
74+
payload = append(payload, t)
75+
}
6676
}
6777

68-
r, err := json.Marshal(featureMap)
78+
r, err := json.Marshal(payload)
6979
if err != nil {
7080
return nil, fmt.Errorf("failed to marshal features: %w", err)
7181
}
@@ -76,7 +86,7 @@ func ListAvailableToolsets(toolsetGroup *toolsets.ToolsetGroup, t translations.T
7686

7787
func GetToolsetsTools(toolsetGroup *toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
7888
return mcp.NewTool("get_toolset_tools",
79-
mcp.WithDescription(t("TOOL_GET_TOOLSET_TOOLS_DESCRIPTION", "Lists all the capabilities that are enabled when you enabled a toolset, use this to get clarity on whether enabling a toolset would help you to complete a task")),
89+
mcp.WithDescription(t("TOOL_GET_TOOLSET_TOOLS_DESCRIPTION", "Lists all the capabilities that are enabled with the specified toolset, use this to get clarity on whether enabling a toolset would help you to complete a task")),
8090
mcp.WithString("toolset",
8191
mcp.Required(),
8292
mcp.Description("The name of the toolset you want to get the tools for"),
@@ -93,14 +103,19 @@ func GetToolsetsTools(toolsetGroup *toolsets.ToolsetGroup, t translations.Transl
93103
if toolset == nil {
94104
return mcp.NewToolResultError(fmt.Sprintf("Toolset %s not found", toolsetName)), nil
95105
}
106+
payload := []map[string]string{}
96107

97-
tools := make(map[string]string)
98-
99-
for _, st := range toolset.GetActiveTools() {
100-
tools[st.Tool.Name] = st.Tool.Description
108+
for _, st := range toolset.GetAvailableTools() {
109+
tool := map[string]string{
110+
"name": st.Tool.Name,
111+
"description": st.Tool.Description,
112+
"can_enable": "true",
113+
"toolset": toolsetName,
114+
}
115+
payload = append(payload, tool)
101116
}
102117

103-
r, err := json.Marshal(tools)
118+
r, err := json.Marshal(payload)
104119
if err != nil {
105120
return nil, fmt.Errorf("failed to marshal features: %w", err)
106121
}

0 commit comments

Comments
 (0)