36 lines
665 B
Go
36 lines
665 B
Go
package tools
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"gitea.d-ma.be/mathias/gitea-mcp/internal/registry"
|
|
)
|
|
|
|
// Tool implements registry.Tool.
|
|
type Tool = registry.Tool
|
|
|
|
func textOK(v any) (json.RawMessage, error) {
|
|
return json.Marshal(v)
|
|
}
|
|
|
|
func parseArgs(raw json.RawMessage, dst any) error {
|
|
if len(raw) == 0 {
|
|
return json.Unmarshal([]byte("{}"), dst)
|
|
}
|
|
return json.Unmarshal(raw, dst)
|
|
}
|
|
|
|
func _ctx(ctx context.Context) context.Context { return ctx } // stub for future hooks
|
|
|
|
// capLimit returns a sane page size: 0 or negative → def, > 50 → 50.
|
|
func capLimit(in, def int) int {
|
|
if in <= 0 {
|
|
return def
|
|
}
|
|
if in > 50 {
|
|
return 50
|
|
}
|
|
return in
|
|
}
|