mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 14:23:05 +00:00
Support read only mode (#36)
Fix: #35 Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/36 Co-authored-by: hiifong <f@ilo.nz> Co-committed-by: hiifong <f@ilo.nz>
This commit is contained in:
@@ -8,5 +8,6 @@ var (
|
||||
Mode string
|
||||
|
||||
Insecure bool
|
||||
ReadOnly bool
|
||||
Debug bool
|
||||
)
|
||||
|
37
pkg/tool/tool.go
Normal file
37
pkg/tool/tool.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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, 100),
|
||||
read: make([]server.ServerTool, 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
|
||||
}
|
Reference in New Issue
Block a user