| 25 | ) |
| 26 | |
| 27 | func GetCommit(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 28 | return NewTool( |
| 29 | ToolsetMetadataRepos, |
| 30 | mcp.Tool{ |
| 31 | Name: "get_commit", |
| 32 | Description: t("TOOL_GET_COMMITS_DESCRIPTION", "Get details for a commit from a GitHub repository"), |
| 33 | Annotations: &mcp.ToolAnnotations{ |
| 34 | Title: t("TOOL_GET_COMMITS_USER_TITLE", "Get commit details"), |
| 35 | ReadOnlyHint: true, |
| 36 | }, |
| 37 | InputSchema: WithPagination(&jsonschema.Schema{ |
| 38 | Type: "object", |
| 39 | Properties: map[string]*jsonschema.Schema{ |
| 40 | "owner": { |
| 41 | Type: "string", |
| 42 | Description: "Repository owner", |
| 43 | }, |
| 44 | "repo": { |
| 45 | Type: "string", |
| 46 | Description: "Repository name", |
| 47 | }, |
| 48 | "sha": { |
| 49 | Type: "string", |
| 50 | Description: "Commit SHA, branch name, or tag name", |
| 51 | }, |
| 52 | "detail": { |
| 53 | Type: "string", |
| 54 | Enum: []any{"none", "stats", "full_patch"}, |
| 55 | Description: "Level of detail to include for changed files. \"none\" omits stats and files entirely. \"stats\" (default) includes per-file metadata: filename, status, and lines-of-code counts (additions, deletions, changes), with no patch content. \"full_patch\" additionally includes the unified diff content for each file and can be very large.", |
| 56 | Default: json.RawMessage(`"stats"`), |
| 57 | }, |
| 58 | }, |
| 59 | Required: []string{"owner", "repo", "sha"}, |
| 60 | }), |
| 61 | }, |
| 62 | []scopes.Scope{scopes.Repo}, |
| 63 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 64 | owner, err := RequiredParam[string](args, "owner") |
| 65 | if err != nil { |
| 66 | return utils.NewToolResultError(err.Error()), nil, nil |
| 67 | } |
| 68 | repo, err := RequiredParam[string](args, "repo") |
| 69 | if err != nil { |
| 70 | return utils.NewToolResultError(err.Error()), nil, nil |
| 71 | } |
| 72 | sha, err := RequiredParam[string](args, "sha") |
| 73 | if err != nil { |
| 74 | return utils.NewToolResultError(err.Error()), nil, nil |
| 75 | } |
| 76 | detailRaw, err := OptionalParam[string](args, "detail") |
| 77 | if err != nil { |
| 78 | return utils.NewToolResultError(err.Error()), nil, nil |
| 79 | } |
| 80 | detail, err := parseCommitDetail(detailRaw) |
| 81 | if err != nil { |
| 82 | return utils.NewToolResultError(err.Error()), nil, nil |
| 83 | } |
| 84 | pagination, err := OptionalPaginationParams(args) |