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>
26 lines
451 B
Go
26 lines
451 B
Go
package label
|
|
|
|
import (
|
|
"testing"
|
|
|
|
gitea_sdk "code.gitea.io/sdk/gitea"
|
|
)
|
|
|
|
func TestSlimLabel(t *testing.T) {
|
|
l := &gitea_sdk.Label{
|
|
ID: 1,
|
|
Name: "bug",
|
|
Color: "#d73a4a",
|
|
Description: "Something isn't working",
|
|
Exclusive: false,
|
|
}
|
|
|
|
m := slimLabel(l)
|
|
if m["name"] != "bug" {
|
|
t.Errorf("expected name bug, got %v", m["name"])
|
|
}
|
|
if m["color"] != "#d73a4a" {
|
|
t.Errorf("expected color, got %v", m["color"])
|
|
}
|
|
}
|