You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnnil, fmt.Errorf("failed to get pod containers: %w", err)
177
215
}
178
216
179
-
responseData:=map[string]interface{}{
180
-
"namespace": params.Namespace,
181
-
"pod": params.Name,
217
+
returnresponse.JSON(map[string]interface{}{
182
218
"containers": containers,
183
-
}
219
+
})
220
+
}
184
221
185
-
returnresponse.JSON(responseData)
222
+
// GetTools returns all log-related MCP tools provided by this handler.
223
+
// This includes tools for retrieving filtered pod logs and discovering
224
+
// containers within pods.
225
+
func (h*LogHandler) GetTools() []MCPTool {
226
+
return []MCPTool{
227
+
NewMCPTool(
228
+
mcp.NewTool("get_logs",
229
+
mcp.WithDescription("Get pod logs with advanced filtering options including grep patterns, time filtering, and previous logs"),
230
+
mcp.WithString("namespace",
231
+
mcp.Required(),
232
+
mcp.Description("Pod namespace"),
233
+
),
234
+
mcp.WithString("name",
235
+
mcp.Required(),
236
+
mcp.Description("Pod name"),
237
+
),
238
+
mcp.WithString("container",
239
+
mcp.Description("Container name (required for multi-container pods)"),
240
+
),
241
+
mcp.WithString("context",
242
+
mcp.Description("Kubernetes context to use (defaults to current context from kubeconfig)"),
243
+
),
244
+
mcp.WithString("max_lines",
245
+
mcp.Description("Maximum number of lines to retrieve"),
246
+
),
247
+
mcp.WithString("grep_include",
248
+
mcp.Description("Include only lines matching these patterns (comma-separated). Works like grep - includes lines containing any of these patterns"),
249
+
),
250
+
mcp.WithString("grep_exclude",
251
+
mcp.Description("Exclude lines matching these patterns (comma-separated). Works like grep -v - excludes lines containing any of these patterns"),
252
+
),
253
+
mcp.WithBoolean("use_regex",
254
+
mcp.Description("Whether to treat grep patterns as regular expressions instead of literal strings"),
255
+
),
256
+
mcp.WithString("since",
257
+
mcp.Description("Return logs newer than this time. Supports durations like \"5m\", \"1h\", \"2h30m\", \"1d\" or absolute times like \"2023-01-01T10:00:00Z\""),
258
+
),
259
+
mcp.WithBoolean("previous",
260
+
mcp.Description("Return logs from the previous terminated container instance (like kubectl logs --previous)"),
261
+
),
262
+
),
263
+
h.GetLogs,
264
+
),
265
+
NewMCPTool(
266
+
mcp.NewTool("get_pod_containers",
267
+
mcp.WithDescription("List containers in a pod for log access"),
268
+
mcp.WithString("namespace",
269
+
mcp.Required(),
270
+
mcp.Description("Pod namespace"),
271
+
),
272
+
mcp.WithString("name",
273
+
mcp.Required(),
274
+
mcp.Description("Pod name"),
275
+
),
276
+
mcp.WithString("context",
277
+
mcp.Description("Kubernetes context to use (defaults to current context from kubeconfig)"),
0 commit comments