feat: P0 LLM-readiness — Chrome aislado (9333), tab_select determinista, page_get_text, page_perceive
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mark3labs/mcp-go/server"
|
||||
@@ -85,10 +86,16 @@ func registerTools(s *server.MCPServer, d *deps) {
|
||||
registerStorageTools(s, d)
|
||||
}
|
||||
|
||||
// portOr returns the CDP port, defaulting to 9222 when zero.
|
||||
// portOr returns the CDP port, defaulting to 9333 when zero.
|
||||
//
|
||||
// SECURITY (P0.3): the default is 9333 — the MCP's OWN isolated Chrome — NOT
|
||||
// 9222. Port 9222 is the user's daily chromium (CDP enabled globally via
|
||||
// /etc/chromium.d/cdp). Defaulting there would let the agent drive the user's
|
||||
// banking/email tabs. The MCP operates on its dedicated browser by default;
|
||||
// pass port=9222 explicitly only to deliberately attach to the daily browser.
|
||||
func portOr(p int) int {
|
||||
if p == 0 {
|
||||
return 9222
|
||||
return 9333
|
||||
}
|
||||
return p
|
||||
}
|
||||
@@ -172,3 +179,28 @@ func truncate(s string, n int) string {
|
||||
}
|
||||
return s[:n] + "\n... [truncated]"
|
||||
}
|
||||
|
||||
// resolveRoot finds the fn_registry root so we can locate the `fn` binary and
|
||||
// the Python venv at runtime. Mirrors registry_mcp's resolveRoot: honors
|
||||
// FN_REGISTRY_ROOT, otherwise walks up from cwd looking for registry.db.
|
||||
func resolveRoot() (string, error) {
|
||||
if env := os.Getenv("FN_REGISTRY_ROOT"); env != "" {
|
||||
return filepath.Abs(env)
|
||||
}
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
dir := cwd
|
||||
for {
|
||||
if _, err := os.Stat(filepath.Join(dir, "registry.db")); err == nil {
|
||||
return dir, nil
|
||||
}
|
||||
parent := filepath.Dir(dir)
|
||||
if parent == dir {
|
||||
break
|
||||
}
|
||||
dir = parent
|
||||
}
|
||||
return "", fmt.Errorf("registry.db not found upward from %s", cwd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user