Files
wdh-home 05ee541420
Some checks failed
CI / init (push) Has been cancelled
CI / Frontend node 18.16.0 (push) Has been cancelled
CI / Backend go (1.22) (push) Has been cancelled
CI / devops-test (1.22, 18.16.0) (push) Has been cancelled
CI / release-pr (push) Has been cancelled
CI / release-please (push) Has been cancelled
CI / devops-prod (1.22, 18.x) (push) Has been cancelled
CI / docker (push) Has been cancelled
init
2026-04-21 16:50:31 +08:00

57 lines
1.5 KiB
Smarty
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package mcpTool
import (
"context"
"github.com/mark3labs/mcp-go/mcp"
)
func init() {
RegisterTool(&{{.Name | title}}{})
}
type {{.Name | title}} struct {
}
// {{.Description}}
func (t *{{.Name | title}}) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// TODO:
// :
// {{- range .Params}}
// {{.Name}} := request.GetArguments()["{{.Name}}"]
// {{- end}}
return &mcp.CallToolResult{
Content: []mcp.Content{
{{- range .Response}}
mcp.{{.Type | title}}Content{
Type: "{{.Type}}",
// TODO: {{.Type}}
},
{{- end}}
},
}, nil
}
func (t *{{.Name | title}}) New() mcp.Tool {
return mcp.NewTool("{{.Name}}",
mcp.WithDescription("{{.Description}}"),
{{- range .Params}}
mcp.With{{.Type | title}}("{{.Name}}",
{{- if .Required}}mcp.Required(),{{end}}
mcp.Description("{{.Description}}"),
{{- if .Default}}
{{- if eq .Type "string"}}
mcp.DefaultString("{{.Default}}"),
{{- else if eq .Type "number"}}
mcp.DefaultNumber({{.Default}}),
{{- else if eq .Type "boolean"}}
mcp.DefaultBoolean({{if or (eq .Default "true") (eq .Default "True")}}true{{else}}false{{end}}),
{{- else if eq .Type "array"}}
//
// mcp.DefaultArray({{.Default}}),
{{- end}}
{{- end}}
),
{{- end}}
)
}