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

Commit2075a36

Browse files
committed
Notifications Mark as done with number implementation
1 parentbdb59e0 commit2075a36

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

‎pkg/github/notifications.go

Lines changed: 39 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"
@@ -234,3 +235,41 @@ func getNotificationThread(client *github.Client, t translations.TranslationHelp
234235
returnmcp.NewToolResultText(string(r)),nil
235236
}
236237
}
238+
239+
// markNotificationDone creates a tool to mark a notification as done.
240+
funcmarkNotificationDone(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
241+
returnmcp.NewTool("mark_notification_done",
242+
mcp.WithDescription(t("TOOL_MARK_NOTIFICATION_DONE_DESCRIPTION","Mark a notification as done")),
243+
mcp.WithString("threadID",
244+
mcp.Required(),
245+
mcp.Description("The ID of the notification thread"),
246+
),
247+
),
248+
func(ctx context.Context,request mcp.CallToolRequest) (*mcp.CallToolResult,error) {
249+
threadIDStr,err:=requiredParam[string](request,"threadID")
250+
iferr!=nil {
251+
returnmcp.NewToolResultError(err.Error()),nil
252+
}
253+
254+
threadID,err:=strconv.ParseInt(threadIDStr,10,64)
255+
iferr!=nil {
256+
returnmcp.NewToolResultError("Invalid threadID: must be a numeric value"),nil
257+
}
258+
259+
resp,err:=client.Activity.MarkThreadDone(ctx,threadID)
260+
iferr!=nil {
261+
returnnil,fmt.Errorf("failed to mark notification as done: %w",err)
262+
}
263+
deferfunc() {_=resp.Body.Close() }()
264+
265+
ifresp.StatusCode!=http.StatusResetContent&&resp.StatusCode!=http.StatusOK {
266+
body,err:=io.ReadAll(resp.Body)
267+
iferr!=nil {
268+
returnnil,fmt.Errorf("failed to read response body: %w",err)
269+
}
270+
returnmcp.NewToolResultError(fmt.Sprintf("failed to mark notification as done: %s",string(body))),nil
271+
}
272+
273+
returnmcp.NewToolResultText("Notification marked as done"),nil
274+
}
275+
}

‎pkg/github/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func NewServer(client *github.Client, readOnly bool, t translations.TranslationH
8484
if!readOnly {
8585
s.AddTool(markNotificationRead(client,t))
8686
s.AddTool(markAllNotificationsRead(client,t))
87+
s.AddTool(markNotificationDone(client,t))
8788
}
8889
returns
8990
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp