feat(page_collect_console): expone max_entries (cap + backlog descartado)
This commit is contained in:
+4
-2
@@ -35,13 +35,15 @@ func registerReadTools(s *server.MCPServer, d *deps) {
|
||||
type pageCollectConsoleArgs struct {
|
||||
Port int `json:"port"`
|
||||
DurationMs int `json:"duration_ms"`
|
||||
MaxEntries int `json:"max_entries"`
|
||||
}
|
||||
|
||||
func pageCollectConsoleTool() mcp.Tool {
|
||||
return mcp.NewTool("page_collect_console",
|
||||
mcp.WithDescription("Capture the page's console output (console.log/info/warn/error), uncaught JS exceptions and browser log entries during a time window, and return them as JSON. It is a SNAPSHOT: it records what happens during duration_ms AFTER the call starts, not past history — so trigger the action you want to observe (reload, click) right before or during the window. Use this to debug why a page misbehaves without flying blind."),
|
||||
mcp.WithDescription("Capture the page's console output (console.log/info/warn/error), uncaught JS exceptions and browser log entries during a time window, and return them as JSON. It is a SNAPSHOT: it records only what happens during duration_ms AFTER the call starts (past backlog is discarded) — so trigger the action you want to observe (reload, click) right before or during the window. Capped at max_entries (default 200) to avoid flooding on verbose pages. Use this to debug why a page misbehaves without flying blind."),
|
||||
mcp.WithNumber("port", mcp.Description("CDP port. Default 9333 (Chrome isolated del MCP); usa 9222 explícito solo para adjuntarte al navegador diario.")),
|
||||
mcp.WithNumber("duration_ms", mcp.Description("Capture window in milliseconds. Default 1500.")),
|
||||
mcp.WithNumber("max_entries", mcp.Description("Max entries returned before truncating. Default 200.")),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,7 +51,7 @@ func (d *deps) handlePageCollectConsole(_ context.Context, _ mcp.CallToolRequest
|
||||
var entries []browser.ConsoleEntry
|
||||
err := d.withConn(portOr(a.Port), func(c *browser.CDPConn) error {
|
||||
var e error
|
||||
entries, e = browser.CdpCollectConsole(c, a.DurationMs)
|
||||
entries, e = browser.CdpCollectConsole(c, a.DurationMs, a.MaxEntries)
|
||||
return e
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user