baf792b061
Use `golangci-lint fmt` to format code, replacing the previous gofumpt-based formatter. https://github.com/daixiang0/gci is used to order the imports. Mirrors https://github.com/go-gitea/gitea/pull/37194. --- This PR was written with the help of Claude Opus 4.7 Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/178 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-committed-by: silverwind <me@silverwind.io>
39 lines
742 B
Go
39 lines
742 B
Go
package tool
|
|
|
|
import (
|
|
"gitea.com/gitea/gitea-mcp/pkg/flag"
|
|
|
|
"github.com/mark3labs/mcp-go/server"
|
|
)
|
|
|
|
type Tool struct {
|
|
write []server.ServerTool
|
|
read []server.ServerTool
|
|
}
|
|
|
|
func New() *Tool {
|
|
return &Tool{
|
|
write: make([]server.ServerTool, 0, 100),
|
|
read: make([]server.ServerTool, 0, 100),
|
|
}
|
|
}
|
|
|
|
func (t *Tool) RegisterWrite(s server.ServerTool) {
|
|
t.write = append(t.write, s)
|
|
}
|
|
|
|
func (t *Tool) RegisterRead(s server.ServerTool) {
|
|
t.read = append(t.read, s)
|
|
}
|
|
|
|
func (t *Tool) Tools() []server.ServerTool {
|
|
tools := make([]server.ServerTool, 0, len(t.write)+len(t.read))
|
|
if flag.ReadOnly {
|
|
tools = append(tools, t.read...)
|
|
return tools
|
|
}
|
|
tools = append(tools, t.write...)
|
|
tools = append(tools, t.read...)
|
|
return tools
|
|
}
|