@@ -3,7 +3,6 @@ package tools
33import (
44 "fmt"
55 "log/slog"
6- "os"
76 "time"
87
98 "github.com/mark3labs/mcp-go/mcp"
@@ -61,8 +60,6 @@ func RequiredPermissionsFromTool(tool mcp.Tool) []string {
6160// --- Time-window support for k8s_list_* Monitor tools --------------------
6261
6362const (
64- maxIntervalEnvVar = "SYSDIG_MCP_MAX_INTERVAL"
65- defaultMaxInterval = 168 * time .Hour // 7 days
6663 windowedQueryTimeout = "60s"
6764 timeParamStart = "start"
6865 timeParamEnd = "end"
@@ -115,12 +112,11 @@ func WithTimeWindowParams() mcp.ToolOption {
115112// ParseTimeWindow reads "start" and "end" from the request, validates them, and returns
116113// the resolved TimeWindow.
117114//
118- // - Both absent: returns zero-value TimeWindow, nil error.
119- // - end without start: error ("end requires start").
120- // - start without end: end = clk.Now().
121- // - invalid RFC3339: error naming the bad field.
122- // - end <= start: error.
123- // - end - start > maxInterval(): error referencing SYSDIG_MCP_MAX_INTERVAL.
115+ // - Both absent: returns zero-value TimeWindow, nil error.
116+ // - end without start: error ("end requires start").
117+ // - start without end: end = clk.Now().
118+ // - invalid RFC3339: error naming the bad field.
119+ // - end <= start: error.
124120func ParseTimeWindow (request mcp.CallToolRequest , clk clock.Clock ) (TimeWindow , error ) {
125121 startStr := mcp .ParseString (request , timeParamStart , "" )
126122 endStr := mcp .ParseString (request , timeParamEnd , "" )
@@ -158,26 +154,9 @@ func ParseTimeWindow(request mcp.CallToolRequest, clk clock.Clock) (TimeWindow,
158154 return TimeWindow {}, fmt .Errorf ("end (%s) must be after start (%s)" , end .Format (time .RFC3339 ), start .Format (time .RFC3339 ))
159155 }
160156
161- window := end .Sub (start )
162- if max := maxInterval (); window > max {
163- return TimeWindow {}, fmt .Errorf ("requested window (%s) exceeds maximum allowed (%s); set %s to raise the cap" , window , max , maxIntervalEnvVar )
164- }
165-
166157 return TimeWindow {Start : start , End : end }, nil
167158}
168159
169- // maxInterval returns the configured maximum window duration. The SYSDIG_MCP_MAX_INTERVAL
170- // env var is read on every call (not cached) so tests can override it via t.Setenv without
171- // bumping into sync.Once-style staleness.
172- func maxInterval () time.Duration {
173- if v := os .Getenv (maxIntervalEnvVar ); v != "" {
174- if d , err := time .ParseDuration (v ); err == nil && d > 0 {
175- return d
176- }
177- }
178- return defaultMaxInterval
179- }
180-
181160// requestHasArg reports whether the caller explicitly supplied the named argument
182161// (distinguishes "user passed empty string" from "user didn't pass the key at all").
183162func requestHasArg (request mcp.CallToolRequest , name string ) bool {
0 commit comments