@@ -15,7 +15,7 @@ import (
1515)
1616
1717// getNotifications creates a tool to list notifications for the current user.
18- func getNotifications ( client * github. Client , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
18+ func GetNotifications ( getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
1919 return mcp .NewTool ("get_notifications" ,
2020 mcp .WithDescription (t ("TOOL_GET_NOTIFICATIONS_DESCRIPTION" , "Get notifications for the authenticated GitHub user" )),
2121 mcp .WithBoolean ("all" ,
@@ -38,33 +38,38 @@ func getNotifications(client *github.Client, t translations.TranslationHelperFun
3838 ),
3939 ),
4040 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
41+ client , err := getClient (ctx )
42+ if err != nil {
43+ return nil , fmt .Errorf ("failed to get GitHub client: %w" , err )
44+ }
45+
4146 // Extract optional parameters with defaults
42- all , err := optionalParamWithDefault [ bool ] (request , "all" , false )
47+ all , err := OptionalBoolParamWithDefault (request , "all" , false )
4348 if err != nil {
4449 return mcp .NewToolResultError (err .Error ()), nil
4550 }
4651
47- participating , err := optionalParamWithDefault [ bool ] (request , "participating" , false )
52+ participating , err := OptionalBoolParamWithDefault (request , "participating" , false )
4853 if err != nil {
4954 return mcp .NewToolResultError (err .Error ()), nil
5055 }
5156
52- since , err := optionalParam [ string ] (request , "since" )
57+ since , err := OptionalStringParamWithDefault (request , "since" , " " )
5358 if err != nil {
5459 return mcp .NewToolResultError (err .Error ()), nil
5560 }
5661
57- before , err := optionalParam [ string ] (request , "before" )
62+ before , err := OptionalStringParam (request , "before" )
5863 if err != nil {
5964 return mcp .NewToolResultError (err .Error ()), nil
6065 }
6166
62- perPage , err := optionalIntParamWithDefault (request , "per_page" , 30 )
67+ perPage , err := OptionalIntParamWithDefault (request , "per_page" , 30 )
6368 if err != nil {
6469 return mcp .NewToolResultError (err .Error ()), nil
6570 }
6671
67- page , err := optionalIntParamWithDefault (request , "page" , 1 )
72+ page , err := OptionalIntParamWithDefault (request , "page" , 1 )
6873 if err != nil {
6974 return mcp .NewToolResultError (err .Error ()), nil
7075 }
@@ -122,7 +127,7 @@ func getNotifications(client *github.Client, t translations.TranslationHelperFun
122127}
123128
124129// markNotificationRead creates a tool to mark a notification as read.
125- func markNotificationRead ( client * github. Client , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
130+ func MarkNotificationRead ( getclient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
126131 return mcp .NewTool ("mark_notification_read" ,
127132 mcp .WithDescription (t ("TOOL_MARK_NOTIFICATION_READ_DESCRIPTION" , "Mark a notification as read" )),
128133 mcp .WithString ("threadID" ,
@@ -131,6 +136,11 @@ func markNotificationRead(client *github.Client, t translations.TranslationHelpe
131136 ),
132137 ),
133138 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
139+ client , err := getclient (ctx )
140+ if err != nil {
141+ return nil , fmt .Errorf ("failed to get GitHub client: %w" , err )
142+ }
143+
134144 threadID , err := requiredParam [string ](request , "threadID" )
135145 if err != nil {
136146 return mcp .NewToolResultError (err .Error ()), nil
@@ -154,16 +164,21 @@ func markNotificationRead(client *github.Client, t translations.TranslationHelpe
154164 }
155165}
156166
157- // markAllNotificationsRead creates a tool to mark all notifications as read.
158- func markAllNotificationsRead ( client * github. Client , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
167+ // MarkAllNotificationsRead creates a tool to mark all notifications as read.
168+ func MarkAllNotificationsRead ( getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
159169 return mcp .NewTool ("mark_all_notifications_read" ,
160170 mcp .WithDescription (t ("TOOL_MARK_ALL_NOTIFICATIONS_READ_DESCRIPTION" , "Mark all notifications as read" )),
161171 mcp .WithString ("lastReadAt" ,
162172 mcp .Description ("Describes the last point that notifications were checked (optional). Default: Now" ),
163173 ),
164174 ),
165175 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
166- lastReadAt , err := optionalParam [string ](request , "lastReadAt" )
176+ client , err := getClient (ctx )
177+ if err != nil {
178+ return nil , fmt .Errorf ("failed to get GitHub client: %w" , err )
179+ }
180+
181+ lastReadAt , err := OptionalStringParam (request , "lastReadAt" )
167182 if err != nil {
168183 return mcp .NewToolResultError (err .Error ()), nil
169184 }
@@ -197,8 +212,8 @@ func markAllNotificationsRead(client *github.Client, t translations.TranslationH
197212 }
198213}
199214
200- // getNotificationThread creates a tool to get a specific notification thread.
201- func getNotificationThread ( client * github. Client , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
215+ // GetNotificationThread creates a tool to get a specific notification thread.
216+ func GetNotificationThread ( getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
202217 return mcp .NewTool ("get_notification_thread" ,
203218 mcp .WithDescription (t ("TOOL_GET_NOTIFICATION_THREAD_DESCRIPTION" , "Get a specific notification thread" )),
204219 mcp .WithString ("threadID" ,
@@ -207,6 +222,11 @@ func getNotificationThread(client *github.Client, t translations.TranslationHelp
207222 ),
208223 ),
209224 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
225+ client , err := getClient (ctx )
226+ if err != nil {
227+ return nil , fmt .Errorf ("failed to get GitHub client: %w" , err )
228+ }
229+
210230 threadID , err := requiredParam [string ](request , "threadID" )
211231 if err != nil {
212232 return mcp .NewToolResultError (err .Error ()), nil
0 commit comments