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 RepoTree struct { c *gitea.Client a *allowlist.Allowlist } func NewRepoTree(c *gitea.Client, a *allowlist.Allowlist) *RepoTree { return &RepoTree{c: c, a: a} } func (t *RepoTree) Descriptor() registry.ToolDescriptor { return registry.ToolDescriptor{ Name: "repo_tree", Description: "Get the full recursive file tree for a repo ref (branch, tag, or SHA).", InputSchema: json.RawMessage(`{ "type":"object", "properties":{ "owner":{"type":"string"}, "name":{"type":"string"}, "ref":{"type":"string","description":"Branch, tag, or commit SHA."} }, "required":["owner","name","ref"] }`), } } type repoTreeArgs struct { Owner string `json:"owner"` Name string `json:"name"` Ref string `json:"ref"` } func (t *RepoTree) Call(ctx context.Context, raw json.RawMessage) (json.RawMessage, error) { var args repoTreeArgs if err := parseArgs(raw, &args); err != nil { return nil, err } if err := t.a.Check(args.Owner); err != nil { return nil, err } tree, err := t.c.GetTree(ctx, args.Owner, args.Name, args.Ref, true) if err != nil { return nil, err } return textOK(tree) }