Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions pkg/mcp/testdata/toolsets-kiali-tools.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
[
{
"annotations": {
"title": "Topology: Mesh, Graph, Health, and Status",
"readOnlyHint": true,
"destructiveHint": false,
"openWorldHint": true
},
"description": "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Includes a mesh health summary overview with aggregated counts of healthy, degraded, and failing apps, workloads, and services. Use this for high-level overviews",
"inputSchema": {
"type": "object",
"properties": {
"graphType": {
"default": "versionedApp",
"description": "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'",
"type": "string"
},
"namespace": {
"description": "Optional single namespace to include in the graph (alternative to namespaces)",
"type": "string"
},
"namespaces": {
"description": "Optional comma-separated list of namespaces to include in the graph",
"type": "string"
},
"rateInterval": {
"default": "10m",
"description": "Rate interval for fetching (e.g., '10m', '5m', '1h').",
"type": "string"
}
}
},
"name": "kiali_get_mesh_graph"
},
{
"annotations": {
"title": "Get Metrics for a Resource",
Expand Down Expand Up @@ -249,6 +216,39 @@
},
"name": "kiali_manage_istio_config"
},
{
"annotations": {
"title": "Topology: Mesh, Graph, Health, and Status",
"readOnlyHint": true,
"destructiveHint": false,
"openWorldHint": true
},
"description": "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Includes a mesh health summary overview with aggregated counts of healthy, degraded, and failing apps, workloads, and services. Use this for high-level overviews",
"inputSchema": {
"type": "object",
"properties": {
"graphType": {
"default": "versionedApp",
"description": "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'",
"type": "string"
},
"namespace": {
"description": "Optional single namespace to include in the graph (alternative to namespaces)",
"type": "string"
},
"namespaces": {
"description": "Optional comma-separated list of namespaces to include in the graph",
"type": "string"
},
"rateInterval": {
"default": "10m",
"description": "Rate interval for fetching (e.g., '10m', '5m', '1h').",
"type": "string"
}
}
},
"name": "kiali_mesh_graph"
},
{
"annotations": {
"title": "Workload: Logs",
Expand Down Expand Up @@ -287,6 +287,6 @@
"workload"
]
},
"name": "workload_logs"
"name": "kiali_workload_logs"
}
]
22 changes: 22 additions & 0 deletions pkg/toolsets/kiali/internal/defaults/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package defaults

const (
DefaultToolsetName = "kiali"
DefaultToolsetDescription = "Most common tools for managing Kiali, check the [Kiali documentation](https://github.com/containers/kubernetes-mcp-server/blob/main/docs/KIALI.md) for more details."
)

func ToolsetName() string {
overrideName := ToolsetNameOverride()
if overrideName != "" {
return overrideName
}
return DefaultToolsetName
}

func ToolsetDescription() string {
overrideDescription := ToolsetDescriptionOverride()
if overrideDescription != "" {
return overrideDescription
}
return DefaultToolsetDescription
}
14 changes: 14 additions & 0 deletions pkg/toolsets/kiali/internal/defaults/defaults_override.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package defaults

const (
toolsetNameOverride = ""
toolsetDescriptionOverride = ""
)

func ToolsetNameOverride() string {
return toolsetNameOverride
}

func ToolsetDescriptionOverride() string {
return toolsetDescriptionOverride
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"fmt"
Expand All @@ -9,13 +9,15 @@ import (

"github.com/containers/kubernetes-mcp-server/pkg/api"
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
)

func initGetMeshGraph() []api.ServerTool {
func InitGetMeshGraph() []api.ServerTool {
ret := make([]api.ServerTool, 0)
name := defaults.ToolsetName() + "_mesh_graph"
ret = append(ret, api.ServerTool{
Tool: api.Tool{
Name: "kiali_get_mesh_graph",
Name: name,
Description: "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Includes a mesh health summary overview with aggregated counts of healthy, degraded, and failing apps, workloads, and services. Use this for high-level overviews",
InputSchema: &jsonschema.Schema{
Type: "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"context"
Expand All @@ -10,6 +10,7 @@ import (

"github.com/containers/kubernetes-mcp-server/pkg/api"
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
)

type resourceOperations struct {
Expand All @@ -32,12 +33,12 @@ var opsMap = map[string]resourceOperations{
},
}

func initGetMetrics() []api.ServerTool {
func InitGetMetrics() []api.ServerTool {
ret := make([]api.ServerTool, 0)

name := defaults.ToolsetName() + "_get_metrics"
ret = append(ret, api.ServerTool{
Tool: api.Tool{
Name: "kiali_get_metrics",
Name: name,
Description: "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
InputSchema: &jsonschema.Schema{
Type: "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"context"
Expand All @@ -10,6 +10,7 @@ import (

"github.com/containers/kubernetes-mcp-server/pkg/api"
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
)

type listDetailsOperations struct {
Expand Down Expand Up @@ -39,12 +40,12 @@ var listDetailsOpsMap = map[string]listDetailsOperations{
},
}

func initGetResourceDetails() []api.ServerTool {
func InitGetResourceDetails() []api.ServerTool {
ret := make([]api.ServerTool, 0)

name := defaults.ToolsetName() + "_get_resource_details"
ret = append(ret, api.ServerTool{
Tool: api.Tool{
Name: "kiali_get_resource_details",
Name: name,
Description: "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
InputSchema: &jsonschema.Schema{
Type: "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"context"
Expand All @@ -12,6 +12,7 @@ import (

"github.com/containers/kubernetes-mcp-server/pkg/api"
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
)

type tracesOperations struct {
Expand Down Expand Up @@ -40,12 +41,12 @@ var tracesOpsMap = map[string]tracesOperations{
},
}

func initGetTraces() []api.ServerTool {
func InitGetTraces() []api.ServerTool {
ret := make([]api.ServerTool, 0)

name := defaults.ToolsetName() + "_get_traces"
ret = append(ret, api.ServerTool{
Tool: api.Tool{
Name: "kiali_get_traces",
Name: name,
Description: "Gets traces for a specific resource (app, service, workload) in a namespace, or gets detailed information for a specific trace by its ID. If traceId is provided, it returns detailed trace information and other parameters are not required.",
InputSchema: &jsonschema.Schema{
Type: "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"encoding/json"
Expand All @@ -8,15 +8,16 @@ import (
"k8s.io/utils/ptr"

"github.com/containers/kubernetes-mcp-server/pkg/api"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
)

func initLogs() []api.ServerTool {
func InitLogs() []api.ServerTool {
ret := make([]api.ServerTool, 0)

name := defaults.ToolsetName() + "_workload_logs"
// Workload logs tool
ret = append(ret, api.ServerTool{
Tool: api.Tool{
Name: "workload_logs",
Name: name,
Description: "Get logs for a specific workload's pods in a namespace. Only requires namespace and workload name - automatically discovers pods and containers. Optionally filter by container name, time range, and other parameters. Container is auto-detected if not specified.",
InputSchema: &jsonschema.Schema{
Type: "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiali
package tools

import (
"fmt"
Expand All @@ -7,13 +7,15 @@ import (
"k8s.io/utils/ptr"

"github.com/containers/kubernetes-mcp-server/pkg/api"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
)

func initManageIstioConfig() []api.ServerTool {
func InitManageIstioConfig() []api.ServerTool {
ret := make([]api.ServerTool, 0)
name := defaults.ToolsetName() + "_manage_istio_config"
ret = append(ret, api.ServerTool{
Tool: api.Tool{
Name: "kiali_manage_istio_config",
Name: name,
Description: "Manages Istio configuration objects (Gateways, VirtualServices, etc.). Can list (objects and validations), get, create, patch, or delete objects",
InputSchema: &jsonschema.Schema{
Type: "object",
Expand Down
18 changes: 10 additions & 8 deletions pkg/toolsets/kiali/toolset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@ import (
"github.com/containers/kubernetes-mcp-server/pkg/api"
internalk8s "github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets"
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
kialiTools "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/tools"
)

type Toolset struct{}

var _ api.Toolset = (*Toolset)(nil)

func (t *Toolset) GetName() string {
return "kiali"
return defaults.ToolsetName()
}

func (t *Toolset) GetDescription() string {
return "Most common tools for managing Kiali, check the [Kiali documentation](https://github.com/containers/kubernetes-mcp-server/blob/main/docs/KIALI.md) for more details."
return defaults.ToolsetDescription()
}

func (t *Toolset) GetTools(_ internalk8s.Openshift) []api.ServerTool {
return slices.Concat(
initGetMeshGraph(),
initManageIstioConfig(),
initGetResourceDetails(),
initGetMetrics(),
initLogs(),
initGetTraces(),
kialiTools.InitGetMeshGraph(),
kialiTools.InitManageIstioConfig(),
kialiTools.InitGetResourceDetails(),
kialiTools.InitGetMetrics(),
kialiTools.InitLogs(),
kialiTools.InitGetTraces(),
)
}

Expand Down