mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-03-13 16:35:12 +00:00
Reduce token usage by slimming tool responses. Instead of returning full Gitea SDK objects (with nested user/repo objects, avatars, permissions, etc.), each operation now has a colocated `slim.go` that extracts only the fields an LLM needs. List endpoints return even fewer fields than single-item endpoints.
Other changes:
- Add `params` helpers to DRY parameter extraction across 40+ handlers
- Remove `{"Result": ...}` wrapper for flatter responses
- Reduce default pageSize from 100 to 30
Fixes: https://gitea.com/gitea/gitea-mcp/issues/128
*Created by Claude on behalf of @silverwind*
Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/141
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-committed-by: silverwind <me@silverwind.io>
48 lines
1003 B
Go
48 lines
1003 B
Go
package timetracking
|
|
|
|
import (
|
|
gitea_sdk "code.gitea.io/sdk/gitea"
|
|
)
|
|
|
|
func slimStopWatch(s *gitea_sdk.StopWatch) map[string]any {
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
return map[string]any{
|
|
"issue_index": s.IssueIndex,
|
|
"issue_title": s.IssueTitle,
|
|
"repo_name": s.RepoName,
|
|
"repo_owner": s.RepoOwnerName,
|
|
"created": s.Created,
|
|
"seconds": s.Seconds,
|
|
}
|
|
}
|
|
|
|
func slimStopWatches(watches []*gitea_sdk.StopWatch) []map[string]any {
|
|
out := make([]map[string]any, 0, len(watches))
|
|
for _, s := range watches {
|
|
out = append(out, slimStopWatch(s))
|
|
}
|
|
return out
|
|
}
|
|
|
|
func slimTrackedTime(t *gitea_sdk.TrackedTime) map[string]any {
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
return map[string]any{
|
|
"id": t.ID,
|
|
"time": t.Time,
|
|
"user_name": t.UserName,
|
|
"created": t.Created,
|
|
}
|
|
}
|
|
|
|
func slimTrackedTimes(times []*gitea_sdk.TrackedTime) []map[string]any {
|
|
out := make([]map[string]any, 0, len(times))
|
|
for _, t := range times {
|
|
out = append(out, slimTrackedTime(t))
|
|
}
|
|
return out
|
|
}
|