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

Commitedc1ada

Browse files
committed
Notifications Mark as done with number implementation
1 parentf75c234 commitedc1ada

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

‎pkg/github/notifications.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"net/http"
9+
"strconv"
910
"time"
1011

1112
"github.com/github/github-mcp-server/pkg/translations"
@@ -254,3 +255,46 @@ func GetNotificationThread(getClient GetClientFn, t translations.TranslationHelp
254255
returnmcp.NewToolResultText(string(r)),nil
255256
}
256257
}
258+
259+
// markNotificationDone creates a tool to mark a notification as done.
260+
funcMarkNotificationDone(getclientGetClientFn,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
261+
returnmcp.NewTool("mark_notification_done",
262+
mcp.WithDescription(t("TOOL_MARK_NOTIFICATION_DONE_DESCRIPTION","Mark a notification as done")),
263+
mcp.WithString("threadID",
264+
mcp.Required(),
265+
mcp.Description("The ID of the notification thread"),
266+
),
267+
),
268+
func(ctx context.Context,request mcp.CallToolRequest) (*mcp.CallToolResult,error) {
269+
client,err:=getclient(ctx)
270+
iferr!=nil {
271+
returnnil,fmt.Errorf("failed to get GitHub client: %w",err)
272+
}
273+
274+
threadIDStr,err:=requiredParam[string](request,"threadID")
275+
iferr!=nil {
276+
returnmcp.NewToolResultError(err.Error()),nil
277+
}
278+
279+
threadID,err:=strconv.ParseInt(threadIDStr,10,64)
280+
iferr!=nil {
281+
returnmcp.NewToolResultError("Invalid threadID: must be a numeric value"),nil
282+
}
283+
284+
resp,err:=client.Activity.MarkThreadDone(ctx,threadID)
285+
iferr!=nil {
286+
returnnil,fmt.Errorf("failed to mark notification as done: %w",err)
287+
}
288+
deferfunc() {_=resp.Body.Close() }()
289+
290+
ifresp.StatusCode!=http.StatusResetContent&&resp.StatusCode!=http.StatusOK {
291+
body,err:=io.ReadAll(resp.Body)
292+
iferr!=nil {
293+
returnnil,fmt.Errorf("failed to read response body: %w",err)
294+
}
295+
returnmcp.NewToolResultError(fmt.Sprintf("failed to mark notification as done: %s",string(body))),nil
296+
}
297+
298+
returnmcp.NewToolResultText("Notification marked as done"),nil
299+
}
300+
}

‎pkg/github/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func NewServer(getClient GetClientFn, version string, readOnly bool, t translati
9797
if!readOnly {
9898
s.AddTool(MarkNotificationRead(getClient,t))
9999
s.AddTool(MarkAllNotificationsRead(getClient,t))
100+
s.AddTool(MarkNotificationDone(getClient,t))
100101
}
101102

102103
returns

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp