Skip to content

Commit a691354

Browse files
cleanup search_users response
1 parent 8854b2a commit a691354

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkg/github/search.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,28 @@ func SearchUsers(getClient GetClientFn, t translations.TranslationHelperFunc) (t
213213
}
214214
return mcp.NewToolResultError(fmt.Sprintf("failed to search users: %s", string(body))), nil
215215
}
216-
217-
r, err := json.Marshal(result)
216+
// marshal only the login field for each user
217+
type minimalUser struct {
218+
Login string `json:"login"`
219+
ID int64 `json:"id,omitempty"`
220+
HTMLURL string `json:"html_url,omitempty"`
221+
AvatarURL string `json:"avatar_url,omitempty"`
222+
}
223+
minimalUsers := make([]minimalUser, 0, len(result.Users))
224+
for _, user := range result.Users {
225+
if user.Login != nil {
226+
minimalUsers = append(minimalUsers, minimalUser{
227+
Login: *user.Login,
228+
ID: *user.ID,
229+
HTMLURL: *user.HTMLURL,
230+
AvatarURL: *user.AvatarURL,
231+
})
232+
}
233+
}
234+
r, err := json.Marshal(minimalUsers)
218235
if err != nil {
219236
return nil, fmt.Errorf("failed to marshal response: %w", err)
220237
}
221-
222238
return mcp.NewToolResultText(string(r)), nil
223239
}
224240
}

0 commit comments

Comments
 (0)