Skip to content

Commit baef1ce

Browse files
committed
address review comments
1 parent 3ec7f1c commit baef1ce

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ The following sets of tools are available (all on by default):
261261
- `name` (`string`) **(required)** - Name of the Pod to get the logs from
262262
- `namespace` (`string`) - Namespace to get the Pod logs from
263263
- `previous` (`boolean`) - Return previous terminated container logs (Optional)
264-
- `tailLines` (`number`) - Number of lines to retrieve from the end of the logs (Optional, default: 256)
264+
- `tail` (`number`) - Number of lines to retrieve from the end of the logs (Optional, default: 100)
265265

266266
- **pods_run** - Run a Kubernetes Pod in the current or provided namespace with the provided container image and optional name
267267
- `image` (`string`) **(required)** - Container Image to run in the Pod

pkg/kubernetes/pods.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ import (
1717
"k8s.io/client-go/tools/remotecommand"
1818
"k8s.io/metrics/pkg/apis/metrics"
1919
metricsv1beta1api "k8s.io/metrics/pkg/apis/metrics/v1beta1"
20+
"k8s.io/utils/ptr"
2021

2122
"github.com/containers/kubernetes-mcp-server/pkg/version"
2223
)
2324

25+
// Default number of lines to retrieve from the end of the logs
26+
const DefaultTailLines = int64(100)
27+
2428
type PodsTopOptions struct {
2529
metav1.ListOptions
2630
AllNamespaces bool
@@ -107,9 +111,8 @@ func (k *Kubernetes) PodsLog(ctx context.Context, namespace, name, container str
107111
if tailLines > 0 {
108112
logOptions.TailLines = &tailLines
109113
} else {
110-
// Default to 256 lines when not specified
111-
defaultLines := int64(256)
112-
logOptions.TailLines = &defaultLines
114+
// Default to DefaultTailLines lines when not specified
115+
logOptions.TailLines = ptr.To(DefaultTailLines)
113116
}
114117

115118
req := pods.GetLogs(name, logOptions)

pkg/toolsets/core/pods.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ func initPods() []api.ServerTool {
201201
Type: "string",
202202
Description: "Name of the Pod container to get the logs from (Optional)",
203203
},
204-
"tailLines": {
204+
"tail": {
205205
Type: "integer",
206-
Description: "Number of lines to retrieve from the end of the logs (Optional, default: 256)",
207-
Default: api.ToRawMessage(int64(256)),
206+
Description: "Number of lines to retrieve from the end of the logs (Optional, default: 100)",
207+
Default: api.ToRawMessage(kubernetes.DefaultTailLines),
208208
Minimum: ptr.To(float64(0)),
209209
},
210210
"previous": {
@@ -403,7 +403,7 @@ func podsLog(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
403403
previousBool = previous.(bool)
404404
}
405405
// Extract tailLines parameter
406-
tailLines := params.GetArguments()["tailLines"]
406+
tailLines := params.GetArguments()["tail"]
407407
var tailLinesInt int64
408408
if tailLines != nil {
409409
// Convert to int64 - safely handle both float64 (JSON number) and int types
@@ -415,7 +415,7 @@ func podsLog(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
415415
case int64:
416416
tailLinesInt = v
417417
default:
418-
return api.NewToolCallResult("", fmt.Errorf("failed to parse tailLines parameter: expected integer, got %T", tailLines)), nil
418+
return api.NewToolCallResult("", fmt.Errorf("failed to parse tail parameter: expected integer, got %T", tailLines)), nil
419419
}
420420
}
421421

0 commit comments

Comments
 (0)