MCP CLI

Coming Soon — V2.00: MCP integration is coming as part of Kubeshark V2.00. Read the announcement.

The kubeshark mcp command runs an MCP (Model Context Protocol) server over stdio, enabling AI assistants like Claude Desktop, Cursor, and other MCP-compatible clients to query Kubeshark’s network visibility data.


Quick Start

kubeshark mcp --url https://kubeshark.example.com

This starts an MCP server that communicates over stdin/stdout using the MCP protocol, connecting to an existing Kubeshark deployment.

To see available tools:

kubeshark mcp --list-tools --url https://kubeshark.example.com

Configuration for Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Connect directly to an existing Kubeshark deployment:

{
  "mcpServers": {
    "kubeshark": {
      "command": "/path/to/kubeshark",
      "args": ["mcp", "--url", "https://kubeshark.example.com"]
    }
  }
}

In URL mode:

  • Connects directly to the Kubeshark Hub
  • No kubectl or kubeconfig required
  • Cluster management tools (start/stop) are disabled
  • All traffic analysis tools work normally

Proxy Mode

When no --url is provided, the MCP CLI will:

  1. Proxy into the cluster using kubectl port-forward
  2. Connect to deployed Kubeshark if it’s running
  3. All traffic analysis tools work normally
{
  "mcpServers": {
    "kubeshark": {
      "command": "/path/to/kubeshark",
      "args": ["mcp", "--kubeconfig", "/path/to/.kube/config"]
    }
  }
}

By default, proxy mode operates in read-only mode. To enable AI assistants to start or stop Kubeshark, add --allow-destructive:

{
  "mcpServers": {
    "kubeshark": {
      "command": "/path/to/kubeshark",
      "args": ["mcp", "--allow-destructive", "--kubeconfig", "/path/to/.kube/config"]
    }
  }
}

CLI Options

OptionDescription
--urlConnect directly to Kubeshark URL (disables cluster management)
--kubeconfigPath to kubeconfig file for proxy mode
--allow-destructiveEnable destructive operations (start_kubeshark, stop_kubeshark)
--list-toolsList available MCP tools and exit
--mcp-configPrint MCP client configuration JSON and exit

Generate Configuration

To generate the Claude Desktop configuration automatically:

kubeshark mcp --mcp-config --url https://kubeshark.example.com

Output:

{
  "mcpServers": {
    "kubeshark": {
      "command": "/usr/local/bin/kubeshark",
      "args": ["mcp", "--url", "https://kubeshark.example.com"]
    }
  }
}

Examples

# List available tools from a Kubeshark instance
kubeshark mcp --list-tools --url https://kubeshark.example.com

# Use specific kubeconfig (proxy mode)
kubeshark mcp --kubeconfig ~/.kube/config

# Enable destructive operations (proxy mode)
kubeshark mcp --allow-destructive --kubeconfig ~/.kube/config

# Connect to local port-forwarded instance
kubeshark mcp --url http://localhost:8899

Available Tools

The MCP server exposes tools dynamically from the Kubeshark Hub. Use --list-tools to see all available tools.

Traffic Analysis Tools

These tools are fetched from the Hub and work in both URL and proxy modes:

ToolDescription
list_workloadsList pods, services, namespaces with observed traffic
list_api_callsQuery L7 API transactions (HTTP, gRPC, Redis, Kafka, DNS)
get_api_callGet detailed information about a specific API call
get_api_statsGet aggregated API statistics
list_l4_flowsList L4 (TCP/UDP) network flows with traffic stats
get_l4_flow_summaryGet L4 connectivity summary (top talkers, cross-ns traffic)
get_dissection_statusCheck L7 protocol parsing status
enable_dissectionEnable L7 protocol dissection
disable_dissectionDisable L7 protocol dissection
list_snapshotsList all PCAP snapshots
create_snapshotCreate a new PCAP snapshot
get_snapshotGet snapshot details
delete_snapshotDelete a snapshot
export_snapshot_pcapExport snapshot as PCAP file

Cluster Management Tools (Proxy Mode Only)

These tools are only available in proxy mode (without --url):

ToolDescriptionRequires
check_kubeshark_statusCheck if Kubeshark is running (read-only)-
start_kubesharkDeploy Kubeshark to the cluster--allow-destructive
stop_kubesharkRemove Kubeshark from the cluster--allow-destructive

Prompts

The MCP server also provides pre-built prompts for common analysis tasks:

PromptDescription
analyze_trafficAnalyze API traffic patterns and identify issues
find_errorsFind and summarize API errors and failures
trace_requestTrace a request path through microservices
show_topologyShow service communication topology
latency_analysisAnalyze latency patterns and identify slow endpoints
security_auditAudit traffic for security concerns
compare_trafficCompare traffic patterns between time periods
debug_connectionDebug connectivity issues between services

Tool Details

check_kubeshark_status

Checks if Kubeshark is running in the cluster. Safe, read-only operation.

Parameters:

ParameterTypeDescription
release_namespacestringNamespace where Kubeshark is installed (default: “default”)

start_kubeshark

Deploys Kubeshark to the cluster. Requires --allow-destructive flag.

Parameters:

ParameterTypeDescription
namespacesstringComma-separated namespaces to tap (e.g., “default,sock-shop”)
pod_regexstringRegular expression to filter pods (e.g., “frontend.*“)
release_namespacestringNamespace where Kubeshark will be installed

Example:

{
  "namespaces": "default,sock-shop",
  "pod_regex": "frontend.*"
}

stop_kubeshark

Removes Kubeshark from the cluster. Requires --allow-destructive flag.

Parameters:

ParameterTypeDescription
release_namespacestringNamespace where Kubeshark is installed

Example Conversation

+---------------------------------------------------------------------------------+
| Claude Desktop                                                                  |
+---------------------------------------------------------------------------------+
|                                                                                 |
|  User: Show me the L4 network flows in my cluster                               |
|                                                                                 |
|  Claude: I'll query the L4 flows.                                               |
|                                                                                 |
|  [Calling list_l4_flows]                                                        |
|                                                                                 |
|  Here are the active L4 flows:                                                  |
|                                                                                 |
|  1. frontend-pod -> orders-service:8080 (TCP)                                   |
|     Bytes: 1.2MB | Packets: 8,432 | RTT: 2.3ms                                  |
|                                                                                 |
|  2. orders-service -> postgres:5432 (TCP)                                       |
|     Bytes: 456KB | Packets: 3,211 | RTT: 0.8ms                                  |
|                                                                                 |
|  User: Show me HTTP 500 errors in the last hour                                 |
|                                                                                 |
|  Claude: I'll query the API traffic for 500 errors.                             |
|                                                                                 |
|  [Calling list_api_calls with kfl="http and response.status == 500"]            |
|                                                                                 |
|  Found 12 HTTP 500 errors:                                                      |
|                                                                                 |
|  1. POST /api/checkout -> payment-service (500)                                 |
|     Time: 10:23:45 | Latency: 2340ms                                            |
|                                                                                 |
|  The payment-service is responsible for 8 of the 12 errors.                     |
|                                                                                 |
+---------------------------------------------------------------------------------+

Troubleshooting

Cannot connect to Kubeshark URL

  1. Verify the URL is accessible: curl https://kubeshark.example.com/api/mcp
  2. Check for authentication requirements
  3. Ensure the Kubeshark Hub has MCP enabled

Cannot connect to cluster (proxy mode)

  1. Verify kubectl works: kubectl get nodes
  2. Check your kubeconfig: kubectl config current-context
  3. Try specifying the kubeconfig explicitly: kubeshark mcp --kubeconfig ~/.kube/config

Cluster management tools disabled

  • In --url mode: Cluster management tools are always disabled
  • In proxy mode without --allow-destructive: Only check_kubeshark_status is available
  • Add --allow-destructive to enable start_kubeshark and stop_kubeshark

MCP server not responding

  1. Test with --list-tools: kubeshark mcp --list-tools --url <your-url>
  2. Check that Kubeshark Hub is running and accessible
  3. Check Claude Desktop logs for errors

What’s Next