package tools import ( "context" "encoding/json" "gitea.d-ma.be/mathias/gitea-mcp/internal/allowlist" "gitea.d-ma.be/mathias/gitea-mcp/internal/gitea" "gitea.d-ma.be/mathias/gitea-mcp/internal/registry" ) type RepoTopicsUpdate struct { c *gitea.Client a *allowlist.Allowlist } func NewRepoTopicsUpdate(c *gitea.Client, a *allowlist.Allowlist) *RepoTopicsUpdate { return &RepoTopicsUpdate{c: c, a: a} } func (t *RepoTopicsUpdate) Descriptor() registry.ToolDescriptor { return registry.ToolDescriptor{ Name: "repo_topics_update", Description: "Replace the topic list for a repository.", InputSchema: json.RawMessage(`{ "type":"object", "properties":{ "owner":{"type":"string"}, "name":{"type":"string"}, "topics":{"type":"array","items":{"type":"string"},"description":"Full replacement list. Send [] to clear all topics."} }, "required":["owner","name","topics"] }`), } } type repoTopicsUpdateArgs struct { Owner string `json:"owner"` Name string `json:"name"` Topics []string `json:"topics"` } func (t *RepoTopicsUpdate) Call(ctx context.Context, raw json.RawMessage) (json.RawMessage, error) { var args repoTopicsUpdateArgs if err := parseArgs(raw, &args); err != nil { return nil, err } if err := t.a.Check(args.Owner); err != nil { return nil, err } if err := t.c.UpdateTopics(ctx, args.Owner, args.Name, args.Topics); err != nil { return nil, err } return textOK(map[string]any{"status": "updated", "topics": args.Topics}) }