You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: convert projects, labels, and dynamic_tools to NewTool pattern
This PR converts projects.go, labels.go, and dynamic_tools.go from the
legacy NewServerToolLegacy wrapper pattern to the new NewTool pattern with
proper ToolDependencies.
Changes:
- projects.go: Convert all 9 project functions to use NewTool with
ToolHandlerFor[map[string]any, any] and 3-return-value handlers
- projects_test.go: Update tests to use new serverTool.Handler(deps) pattern
- labels.go: Convert GetLabel, ListLabels, and LabelWrite to NewTool pattern
- labels_test.go: Update tests to use new pattern
- dynamic_tools.go: Refactor functions to return ServerTool directly
(using NewServerToolLegacy internally since they have special dependencies)
- tools.go: Remove NewServerToolLegacy wrappers for dynamic tools registration
Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
funcEnableToolset(s*mcp.Server, toolsetGroup*toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
24
-
return mcp.Tool{
25
-
Name: "enable_toolset",
26
-
Description: 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"),
27
-
Annotations: &mcp.ToolAnnotations{
28
-
Title: t("TOOL_ENABLE_TOOLSET_USER_TITLE", "Enable a toolset"),
29
-
// Not modifying GitHub data so no need to show a warning
30
-
ReadOnlyHint: true,
31
-
},
32
-
InputSchema: &jsonschema.Schema{
33
-
Type: "object",
34
-
Properties: map[string]*jsonschema.Schema{
35
-
"toolset": {
36
-
Type: "string",
37
-
Description: "The name of the toolset to enable",
38
-
Enum: ToolsetEnum(toolsetGroup),
39
-
},
23
+
funcEnableToolset(s*mcp.Server, toolsetGroup*toolsets.ToolsetGroup, t translations.TranslationHelperFunc) toolsets.ServerTool {
24
+
returntoolsets.NewServerToolLegacy(mcp.Tool{
25
+
Name: "enable_toolset",
26
+
Description: 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"),
27
+
Annotations: &mcp.ToolAnnotations{
28
+
Title: t("TOOL_ENABLE_TOOLSET_USER_TITLE", "Enable a toolset"),
29
+
// Not modifying GitHub data so no need to show a warning
funcListAvailableToolsets(toolsetGroup*toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
71
-
return mcp.Tool{
72
-
Name: "list_available_toolsets",
73
-
Description: t("TOOL_LIST_AVAILABLE_TOOLSETS_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"),
74
-
Annotations: &mcp.ToolAnnotations{
75
-
Title: t("TOOL_LIST_AVAILABLE_TOOLSETS_USER_TITLE", "List available toolsets"),
76
-
ReadOnlyHint: true,
77
-
},
78
-
InputSchema: &jsonschema.Schema{
79
-
Type: "object",
80
-
Properties: map[string]*jsonschema.Schema{},
81
-
},
70
+
funcListAvailableToolsets(toolsetGroup*toolsets.ToolsetGroup, t translations.TranslationHelperFunc) toolsets.ServerTool {
71
+
returntoolsets.NewServerToolLegacy(mcp.Tool{
72
+
Name: "list_available_toolsets",
73
+
Description: t("TOOL_LIST_AVAILABLE_TOOLSETS_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"),
74
+
Annotations: &mcp.ToolAnnotations{
75
+
Title: t("TOOL_LIST_AVAILABLE_TOOLSETS_USER_TITLE", "List available toolsets"),
funcGetToolsetsTools(toolsetGroup*toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
110
-
return mcp.Tool{
111
-
Name: "get_toolset_tools",
112
-
Description: 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"),
113
-
Annotations: &mcp.ToolAnnotations{
114
-
Title: t("TOOL_GET_TOOLSET_TOOLS_USER_TITLE", "List all tools in a toolset"),
115
-
ReadOnlyHint: true,
116
-
},
117
-
InputSchema: &jsonschema.Schema{
118
-
Type: "object",
119
-
Properties: map[string]*jsonschema.Schema{
120
-
"toolset": {
121
-
Type: "string",
122
-
Description: "The name of the toolset you want to get the tools for",
123
-
Enum: ToolsetEnum(toolsetGroup),
124
-
},
109
+
funcGetToolsetsTools(toolsetGroup*toolsets.ToolsetGroup, t translations.TranslationHelperFunc) toolsets.ServerTool {
110
+
returntoolsets.NewServerToolLegacy(mcp.Tool{
111
+
Name: "get_toolset_tools",
112
+
Description: 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"),
113
+
Annotations: &mcp.ToolAnnotations{
114
+
Title: t("TOOL_GET_TOOLSET_TOOLS_USER_TITLE", "List all tools in a toolset"),
115
+
ReadOnlyHint: true,
116
+
},
117
+
InputSchema: &jsonschema.Schema{
118
+
Type: "object",
119
+
Properties: map[string]*jsonschema.Schema{
120
+
"toolset": {
121
+
Type: "string",
122
+
Description: "The name of the toolset you want to get the tools for",
0 commit comments