in pkg/github/dynamic_tools.go [22:60]
func EnableToolset(s *server.MCPServer, toolsetGroup *toolsets.ToolsetGroup, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("enable_toolset",
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")),
mcp.WithToolAnnotation(mcp.ToolAnnotation{
Title: t("TOOL_ENABLE_TOOLSET_USER_TITLE", "Enable a toolset"),
// Not modifying GitHub data so no need to show a warning
ReadOnlyHint: true,
}),
mcp.WithString("toolset",
mcp.Required(),
mcp.Description("The name of the toolset to enable"),
ToolsetEnum(toolsetGroup),
),
),
func(_ context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// We need to convert the toolsets back to a map for JSON serialization
toolsetName, err := requiredParam[string](request, "toolset")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
toolset := toolsetGroup.Toolsets[toolsetName]
if toolset == nil {
return mcp.NewToolResultError(fmt.Sprintf("Toolset %s not found", toolsetName)), nil
}
if toolset.Enabled {
return mcp.NewToolResultText(fmt.Sprintf("Toolset %s is already enabled", toolsetName)), nil
}
toolset.Enabled = true
// caution: this currently affects the global tools and notifies all clients:
//
// Send notification to all initialized sessions
// s.sendNotificationToAllClients("notifications/tools/list_changed", nil)
s.AddTools(toolset.GetActiveTools()...)
return mcp.NewToolResultText(fmt.Sprintf("Toolset %s enabled", toolsetName)), nil
}
}