feat(tools): tool interface + helpers
This commit is contained in:
24
internal/tools/tool.go
Normal file
24
internal/tools/tool.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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
|
||||||
Reference in New Issue
Block a user