Skip to content

Commit dfdc720

Browse files
committed
filter the commits in ListCommits to save tokens
1 parent 7aced2b commit dfdc720

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

github-mcp-server

15.2 MB
Binary file not shown.

pkg/github/repositories.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,23 @@ func ListCommits(getClient GetClientFn, t translations.TranslationHelperFunc) (t
149149
return mcp.NewToolResultError(fmt.Sprintf("failed to list commits: %s", string(body))), nil
150150
}
151151

152-
r, err := json.Marshal(commits)
152+
// Filter commit data to include only required fields
153+
filteredCommits := make([]map[string]interface{}, 0, len(commits))
154+
for _, commit := range commits {
155+
filteredCommit := map[string]interface{}{
156+
"sha": commit.GetSHA(),
157+
"node_id": commit.GetNodeID(),
158+
"commit": map[string]interface{}{
159+
"message": commit.GetCommit().GetMessage(),
160+
"author": map[string]interface{}{
161+
"name": commit.GetCommit().GetAuthor().GetName(),
162+
},
163+
},
164+
}
165+
filteredCommits = append(filteredCommits, filteredCommit)
166+
}
167+
168+
r, err := json.Marshal(filteredCommits)
153169
if err != nil {
154170
return nil, fmt.Errorf("failed to marshal response: %w", err)
155171
}

0 commit comments

Comments
 (0)