diff --git a/pkg/config/config.go b/pkg/config/config.go index 1d507234b..5e4cb8181 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -744,7 +744,7 @@ func (c *ModelConfig) SetAPIKey(value string) { type GatewayConfig struct { Host string `json:"host" env:"PICOCLAW_GATEWAY_HOST"` - Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT,PORT"` + Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT"` APIKey string `json:"api_key" env:"PICOCLAW_GATEWAY_API_KEY"` ChatEnabled bool `json:"chat_enabled" env:"PICOCLAW_GATEWAY_CHAT_ENABLED"` HotReload bool `json:"hot_reload" env:"PICOCLAW_GATEWAY_HOT_RELOAD"` diff --git a/pkg/health/server.go b/pkg/health/server.go index 9b4bc45c5..a4b58c574 100644 --- a/pkg/health/server.go +++ b/pkg/health/server.go @@ -63,11 +63,6 @@ type StatusResponse struct { } func NewServer(host string, port int) *Server { - if envPort := os.Getenv("PORT"); envPort != "" { - if _, err := fmt.Sscanf(envPort, "%d", &port); err == nil { - logger.Infof("Overriding server port with PORT environment variable: %d", port) - } - } mux := http.NewServeMux() s := &Server{ ready: false, diff --git a/pkg/security/policy/checker.go b/pkg/security/policy/checker.go index e749da57f..f4b5e13b7 100644 --- a/pkg/security/policy/checker.go +++ b/pkg/security/policy/checker.go @@ -3,6 +3,7 @@ package policy import ( "context" "fmt" + "strings" "github.com/sipeed/picoclaw/pkg/agent" ) @@ -50,7 +51,26 @@ func (c *Checker) ApproveTool(ctx context.Context, req *agent.ToolApprovalReques // 2. Whitelisting (if enabled) if len(c.Config.AllowedTools) > 0 { - if !c.Config.AllowedTools[req.Tool] { + allowed := false + if c.Config.AllowedTools[req.Tool] { + allowed = true + } else { + // Check for prefix matches (e.g. "monday" matches "mcp_monday_...") + // Match logic consistent with ToolRegistry.Filter + for w, ok := range c.Config.AllowedTools { + if !ok { + continue + } + if strings.HasPrefix(req.Tool, "mcp_"+w+"_") || + strings.HasPrefix(req.Tool, "tool_"+w+"_") || + strings.HasPrefix(req.Tool, w+"_") { + allowed = true + break + } + } + } + + if !allowed { return agent.ApprovalDecision{ Approved: false, Reason: fmt.Sprintf("Tool %q is not in the allowed tools whitelist", req.Tool),