Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Fix ListFilters ignoring event limit and HTTP MCP ignoring command context

Cursor Agent2b77605fd780
diff --git a/cli/beacon/cmd/mcp.go b/cli/beacon/cmd/mcp.go
index f682a7a3..bc4d7e30 100644
--- a/cli/beacon/cmd/mcp.go
+++ b/cli/beacon/cmd/mcp.go
@@ -1,6 +1,8 @@
package cmd
import (
+ "context"
+ "errors"
"fmt"
"net"
"net/http"
@@ -73,12 +75,24 @@ func runMCPServe(cmd *cobra.Command, args []string) error {
}
fmt.Fprintf(os.Stderr, "Beacon MCP server: http://%s/mcp\n", mcpOpts.addr)
fmt.Fprintf(os.Stderr, "Runtime log: %s\n", runtimeLog.EffectiveLogPath)
+ ctx := cmd.Context()
httpServer := &http.Server{
Addr: mcpOpts.addr,
Handler: server.HTTPHandler(),
ReadHeaderTimeout: 5 * time.Second,
+ BaseContext: func(_ net.Listener) context.Context { return ctx },
}
- return httpServer.ListenAndServe()
+ go func() {
+ <-ctx.Done()
+ shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ httpServer.Shutdown(shutdownCtx)
+ }()
+ err := httpServer.ListenAndServe()
+ if errors.Is(err, http.ErrServerClosed) {
+ return nil
+ }
+ return err
default:
return fmt.Errorf("unsupported transport %q", mcpOpts.transport)
}
diff --git a/cli/beacon/internal/endpoint/activity/activity.go b/cli/beacon/internal/endpoint/activity/activity.go
index 3bc5050e..268ec05f 100644
--- a/cli/beacon/internal/endpoint/activity/activity.go
+++ b/cli/beacon/internal/endpoint/activity/activity.go
@@ -221,7 +221,7 @@ func GetEvent(logPath, id string) (EventResult, error) {
}
func ListFilters(query Query) (FilterValuesResult, error) {
- result, err := readAll(query)
+ result, err := read(query)
if err != nil {
return FilterValuesResult{}, err
}
@@ -293,32 +293,6 @@ func InspectLog(logPath string) (sampledEvents, malformedLines int, archives []s
return len(result.Events), result.MalformedLines, archives, nil
}
-func readAll(query Query) (dashboard.EventResult, error) {
- if query.LogPath == "" {
- return dashboard.EventResult{}, fmt.Errorf("runtime log path is required")
- }
- return dashboard.ReadEvents(query.LogPath, dashboard.EventQuery{
- NoLimit: true,
- Since: query.Since,
- Until: query.Until,
- Q: query.Q,
- Harness: query.Harness,
- Model: query.Model,
- Action: query.Action,
- Severity: query.Severity,
- Category: query.Category,
- Repository: query.Repository,
- Session: query.Session,
- File: query.File,
- Command: query.Command,
- MCP: query.MCP,
- Approval: query.Approval,
- Decision: query.Decision,
- Policy: query.Policy,
- Review: query.Review,
- WazuhLevel: query.WazuhLevel,
- })
-}
func read(query Query) (dashboard.EventResult, error) {
if query.LogPath == "" {