MCPcopy
hub / github.com/github/github-mcp-server / GetNotificationDetails

Function GetNotificationDetails

pkg/github/notifications.go:334–399  ·  view source on GitHub ↗

GetNotificationDetails creates a tool to get details for a specific notification.

(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

332
333// GetNotificationDetails creates a tool to get details for a specific notification.
334func GetNotificationDetails(t translations.TranslationHelperFunc) inventory.ServerTool {
335 return NewTool(
336 ToolsetMetadataNotifications,
337 mcp.Tool{
338 Name: "get_notification_details",
339 Description: t("TOOL_GET_NOTIFICATION_DETAILS_DESCRIPTION", "Get detailed information for a specific GitHub notification, always call this tool when the user asks for details about a specific notification, if you don't know the ID list notifications first."),
340 Annotations: &mcp.ToolAnnotations{
341 Title: t("TOOL_GET_NOTIFICATION_DETAILS_USER_TITLE", "Get notification details"),
342 ReadOnlyHint: true,
343 },
344 InputSchema: &jsonschema.Schema{
345 Type: "object",
346 Properties: map[string]*jsonschema.Schema{
347 "notificationID": {
348 Type: "string",
349 Description: "The ID of the notification",
350 },
351 },
352 Required: []string{"notificationID"},
353 },
354 },
355 []scopes.Scope{scopes.Notifications},
356 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
357 client, err := deps.GetClient(ctx)
358 if err != nil {
359 return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
360 }
361
362 notificationID, err := RequiredParam[string](args, "notificationID")
363 if err != nil {
364 return utils.NewToolResultError(err.Error()), nil, nil
365 }
366
367 thread, resp, err := client.Activity.GetThread(ctx, notificationID)
368 if err != nil {
369 return ghErrors.NewGitHubAPIErrorResponse(ctx,
370 fmt.Sprintf("failed to get notification details for ID '%s'", notificationID),
371 resp,
372 err,
373 ), nil, nil
374 }
375 defer func() { _ = resp.Body.Close() }()
376
377 if resp.StatusCode != http.StatusOK {
378 body, err := io.ReadAll(resp.Body)
379 if err != nil {
380 return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil
381 }
382 return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get notification details", resp, body), nil, nil
383 }
384
385 r, err := json.Marshal(thread)
386 if err != nil {
387 return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil
388 }
389
390 result := utils.NewToolResultText(string(r))
391 // A notification subject points at an issue, PR, comment, or

Callers 2

AllToolsFunction · 0.85

Calls 9

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
LabelNotificationDetailsFunction · 0.92
NewToolFunction · 0.85
attachStaticIFCLabelFunction · 0.85
CloseMethod · 0.80
GetClientMethod · 0.65
ErrorMethod · 0.45

Tested by 1