Add package listing and management tools (#170)

Adds `package_read` and `package_write` MCP tools for the Gitea
Packages API.

- `package_read` (read): `list`, `list_versions`, `get`
- `package_write` (write): `delete`

Package names containing slashes (e.g. container image paths like
`my-repo/my-image`) are accepted raw or pre-encoded and URL-encoded
correctly without double-encoding.

Co-Authored-By: silverwind <me@silverwind.io>
Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
Skyf0l
2026-05-10 11:42:01 +02:00
committed by silverwind
parent 329a97d5d2
commit cd82f6f207
4 changed files with 653 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
package packages
func slimPackage(v any) map[string]any {
m, ok := v.(map[string]any)
if !ok {
return nil
}
out := map[string]any{
"id": m["id"],
"type": m["type"],
"name": m["name"],
"version": m["version"],
"html_url": m["html_url"],
"created_at": m["created_at"],
}
if owner, ok := m["owner"].(map[string]any); ok {
out["owner"] = owner["login"]
}
if creator, ok := m["creator"].(map[string]any); ok {
out["creator"] = creator["login"]
}
if repo, ok := m["repository"].(map[string]any); ok {
out["repository"] = repo["full_name"]
}
return out
}
func slimPackages(v any) any {
switch val := v.(type) {
case []any:
out := make([]map[string]any, 0, len(val))
for _, item := range val {
if slim := slimPackage(item); slim != nil {
out = append(out, slim)
}
}
return out
case map[string]any:
return slimPackage(val)
default:
return v
}
}