ListGists creates a tool to list gists for a user
(t translations.TranslationHelperFunc)
| 20 | |
| 21 | // ListGists creates a tool to list gists for a user |
| 22 | func ListGists(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 23 | return NewTool( |
| 24 | ToolsetMetadataGists, |
| 25 | mcp.Tool{ |
| 26 | Name: "list_gists", |
| 27 | Description: t("TOOL_LIST_GISTS_DESCRIPTION", "List gists for a user"), |
| 28 | Annotations: &mcp.ToolAnnotations{ |
| 29 | Title: t("TOOL_LIST_GISTS", "List Gists"), |
| 30 | ReadOnlyHint: true, |
| 31 | }, |
| 32 | InputSchema: WithPagination(&jsonschema.Schema{ |
| 33 | Type: "object", |
| 34 | Properties: map[string]*jsonschema.Schema{ |
| 35 | "username": { |
| 36 | Type: "string", |
| 37 | Description: "GitHub username (omit for authenticated user's gists)", |
| 38 | }, |
| 39 | "since": { |
| 40 | Type: "string", |
| 41 | Description: "Only gists updated after this time (ISO 8601 timestamp)", |
| 42 | }, |
| 43 | }, |
| 44 | }), |
| 45 | }, |
| 46 | nil, |
| 47 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 48 | username, err := OptionalParam[string](args, "username") |
| 49 | if err != nil { |
| 50 | return utils.NewToolResultError(err.Error()), nil, nil |
| 51 | } |
| 52 | |
| 53 | since, err := OptionalParam[string](args, "since") |
| 54 | if err != nil { |
| 55 | return utils.NewToolResultError(err.Error()), nil, nil |
| 56 | } |
| 57 | |
| 58 | pagination, err := OptionalPaginationParams(args) |
| 59 | if err != nil { |
| 60 | return utils.NewToolResultError(err.Error()), nil, nil |
| 61 | } |
| 62 | |
| 63 | opts := &github.GistListOptions{ |
| 64 | ListOptions: github.ListOptions{ |
| 65 | Page: pagination.Page, |
| 66 | PerPage: pagination.PerPage, |
| 67 | }, |
| 68 | } |
| 69 | |
| 70 | // Parse since timestamp if provided |
| 71 | if since != "" { |
| 72 | sinceTime, err := parseISOTimestamp(since) |
| 73 | if err != nil { |
| 74 | return utils.NewToolResultError(fmt.Sprintf("invalid since timestamp: %v", err)), nil, nil |
| 75 | } |
| 76 | opts.Since = sinceTime |
| 77 | } |
| 78 | |
| 79 | client, err := deps.GetClient(ctx) |