@@ -155,6 +155,41 @@ type ListCommitsInput struct {
155155 PerPage * int `json:"perPage,omitempty"`
156156}
157157
158+ type ListCommitOutput struct {
159+ SHA * string `json:"sha,omitempty"`
160+ HTMLURL * string `json:"html_url,omitempty"`
161+ Commit * MinimalCommitInfo `json:"commit,omitempty"`
162+ Author * MinimalUser `json:"author,omitempty"`
163+ Committer * MinimalUser `json:"committer,omitempty"`
164+ }
165+
166+ func structuredListCommitsOutput (commits []MinimalCommit , fields []string ) []ListCommitOutput {
167+ output := make ([]ListCommitOutput , 0 , len (commits ))
168+ selected := func (field string ) bool {
169+ return len (fields ) == 0 || slices .Contains (fields , field )
170+ }
171+ for _ , commit := range commits {
172+ item := ListCommitOutput {}
173+ if selected ("sha" ) {
174+ item .SHA = new (commit.SHA )
175+ }
176+ if selected ("html_url" ) {
177+ item .HTMLURL = new (commit.HTMLURL )
178+ }
179+ if selected ("commit" ) {
180+ item .Commit = commit .Commit
181+ }
182+ if selected ("author" ) {
183+ item .Author = commit .Author
184+ }
185+ if selected ("committer" ) {
186+ item .Committer = commit .Committer
187+ }
188+ output = append (output , item )
189+ }
190+ return output
191+ }
192+
158193func ListCommits (t translations.TranslationHelperFunc ) inventory.ServerTool {
159194 schema := & jsonschema.Schema {
160195 Type : "object" ,
@@ -196,7 +231,7 @@ func ListCommits(t translations.TranslationHelperFunc) inventory.ServerTool {
196231 )
197232 WithPagination (schema )
198233
199- return NewTool [ListCommitsInput , []MinimalCommit ](
234+ return NewTool [ListCommitsInput , []ListCommitOutput ](
200235 ToolsetMetadataRepos ,
201236 mcp.Tool {
202237 Name : "list_commits" ,
@@ -208,7 +243,7 @@ func ListCommits(t translations.TranslationHelperFunc) inventory.ServerTool {
208243 InputSchema : schema ,
209244 },
210245 scopes .PublicRead (scopes .Repo ),
211- func (ctx context.Context , deps ToolDependencies , _ * mcp.CallToolRequest , input ListCommitsInput ) (* mcp.CallToolResult , []MinimalCommit , error ) {
246+ func (ctx context.Context , deps ToolDependencies , _ * mcp.CallToolRequest , input ListCommitsInput ) (* mcp.CallToolResult , []ListCommitOutput , error ) {
212247 if input .Owner == "" {
213248 return utils .NewToolResultError ("missing required parameter: owner" ), nil , nil
214249 }
@@ -302,10 +337,7 @@ func ListCommits(t translations.TranslationHelperFunc) inventory.ServerTool {
302337 // follows the same public-untrusted / private-trusted rule as file
303338 // contents. Confidentiality follows repo visibility.
304339 result = attachRepoVisibilityIFCLabel (ctx , deps , client , input .Owner , input .Repo , result , ifc .LabelCommitContents )
305- if len (input .Fields ) > 0 {
306- return result , nil , nil
307- }
308- return result , minimalCommits , nil
340+ return result , structuredListCommitsOutput (minimalCommits , input .Fields ), nil
309341 },
310342 normalizeTypedReadArguments (nil , false ),
311343 )
0 commit comments