Kubeshark Kubernetes Traffic Analysis
MCP Server
| Property |
Value |
| Source |
kubeshark/kubeshark — MCP docs |
| Transport |
Remote HTTP (JSON-RPC 2.0, default port 8898) |
| Language |
Go (built into Kubeshark Hub) |
| Tools |
6 (capture, export pcap, snapshot, filter, L4 flows, flow summary) |
| Auth |
None (cluster-internal); requires kubectl port-forward for remote access |
| Requires |
Kubernetes cluster with Kubeshark installed via Helm |
How to Run
# Install Kubeshark with MCP enabled
helm install kubeshark kubeshark/kubeshark \
--set mcp.enabled=true \
--set mcp.port=8898
# Port-forward for local access (if not in-cluster)
kubectl port-forward svc/kubeshark-hub 8898:8898
# MCP endpoint is now available at:
# http://localhost:8898/mcp
Environment Variables
| Variable |
Required |
Example |
Description |
KUBESHARK_MCP_URL |
Yes |
http://localhost:8898/mcp |
Kubeshark MCP endpoint URL |
KUBESHARK_MCP_PORT |
No |
8898 |
MCP server port (default: 8898) |
Tools
| Tool |
Parameters |
What It Does |
capture_traffic |
filter?, duration? |
Start targeted packet capture across cluster pods |
export_pcap |
filter?, time_range? |
Export captured traffic as pcap for Wireshark/tshark analysis |
create_snapshot |
filter? |
Create point-in-time traffic snapshot within retention window |
apply_filter |
kfl_expression |
Apply Kubeshark Filter Language (KFL) expressions to narrow results |
list_l4_flows |
filter? |
List TCP/UDP flows with connection stats, RTT metrics, byte counts |
get_l4_flow_summary |
filter? |
High-level summary: top talkers, protocol distribution, traffic volume |
Resources Exposed
- Real-time L7 API streams (HTTP, gRPC, GraphQL, Redis, Kafka, DNS) with full request/response payloads
- Historical traffic queries within the configured retention window
- Decrypted TLS/HTTPS traffic via eBPF (no manual key management)
- TCP/UDP connection flows with timing, RTT, and byte statistics
- Kubernetes pod identity and service mapping (source → destination with namespace/labels)
Workflow: Kubernetes Service Troubleshooting
When investigating connectivity or latency issues between Kubernetes services:
- Capture traffic:
capture_traffic(filter="src.pod.name == 'frontend'") — start targeted capture
- List flows:
list_l4_flows — see all TCP/UDP connections with RTT and stats
- Flow summary:
get_l4_flow_summary — identify top talkers and protocol breakdown
- Apply filter:
apply_filter(kfl_expression="response.status >= 500") — isolate errors
- Export pcap:
export_pcap(filter="dst.pod.name == 'api-gateway'") — export for deep analysis
- Cross-reference: Use
packet-analysis skill to analyze exported pcap with tshark
- Report: Service communication analysis with latency, error rates, and traffic patterns
- GAIT: Record all captures and findings in audit trail
Example: API Gateway Latency Investigation
capture_traffic(filter="dst.pod.name == 'api-gateway'", duration="5m")
list_l4_flows(filter="dst.pod.name == 'api-gateway'")
get_l4_flow_summary(filter="dst.pod.name == 'api-gateway'")
apply_filter(kfl_expression="response.latency > 500ms")
export_pcap(filter="response.latency > 500ms")
Workflow: TLS Traffic Inspection
When investigating encrypted service-to-service communication:
- Capture:
capture_traffic — Kubeshark automatically decrypts TLS via eBPF
- Filter:
apply_filter(kfl_expression="request.headers['content-type'] == 'application/grpc'") — isolate gRPC
- Flows:
list_l4_flows — see encrypted connections with decrypted payload summaries
- Export:
export_pcap — export decrypted traffic for offline analysis
- Report: TLS communication audit with certificate info and payload analysis
Workflow: Incident Traffic Forensics
When performing post-incident traffic analysis:
- Snapshot:
create_snapshot — capture current traffic state
- Historical query:
apply_filter with time range — find traffic around incident time
- Flow analysis:
list_l4_flows — identify unusual connections or traffic spikes
- Top talkers:
get_l4_flow_summary — find services with abnormal traffic volume
- Export evidence:
export_pcap — preserve traffic for incident report
- Cross-reference: Correlate with Prometheus metrics, Grafana alerts, and pyATS device state
Integration with Other Skills
| Skill |
Integration |
| packet-analysis |
Export Kubeshark pcaps → analyze with Packet Buddy tshark (deeper protocol dissection) |
| prometheus-monitoring |
Correlate Kubeshark flow metrics with Prometheus time-series data |
| grafana-observability |
Cross-reference Kubeshark traffic patterns with Grafana dashboards and alerts |
| pyats-health-check |
Compare Kubernetes network traffic with underlying infrastructure health |
| gait-session-tracking |
Record all Kubeshark captures, exports, and analysis in GAIT audit trail |
| servicenow-change-workflow |
Reference Kubeshark traffic captures as evidence in change requests or incidents |
Kubeshark Filter Language (KFL) Examples
# Filter by pod name
src.pod.name == "frontend"
# Filter by namespace
dst.namespace == "production"
# HTTP status codes
response.status >= 400
# Latency threshold
response.latency > 200ms
# Protocol type
protocol == "grpc"
# Combined filters
src.namespace == "default" and response.status >= 500 and response.latency > 1s
# DNS queries
protocol == "dns" and request.query contains "api.internal"
# Kafka messages
protocol == "kafka" and request.topic == "orders"
Important Rules
- All tools are read-only — Kubeshark captures and analyzes traffic but does not modify it
- Cluster access required — Kubeshark must be deployed in the target Kubernetes cluster via Helm
- Port-forward for remote access — use
kubectl port-forward svc/kubeshark-hub 8898:8898 when not in-cluster
- Retention window — historical queries are limited to the configured retention period
- Large captures — use KFL filters to scope captures and avoid overwhelming context with large traffic volumes
- Sensitive data — captured traffic may contain PII, credentials, or secrets in request/response payloads; handle exports accordingly
- GAIT audit mandatory — record all traffic captures, pcap exports, and analysis findings
- No secrets in filters — never embed credentials or sensitive data in KFL expressions
Error Handling
- Connection refused: Verify Kubeshark is running (
kubectl get pods -n kubeshark) and port-forward is active.
- No traffic captured: Check KFL filter syntax; verify target pods exist and are generating traffic.
- MCP endpoint not found: Ensure
mcp.enabled=true in Helm values; verify MCP port matches KUBESHARK_MCP_URL.
- Permission denied: Check RBAC — Kubeshark needs cluster-wide read access for traffic capture.
- Empty pcap exports: Verify retention window covers the requested time range; check that traffic matching the filter exists.
1---
2name: kubeshark-traffic
3description: "Kubeshark Kubernetes traffic analysis — L4/L7 deep packet inspection, TLS decryption, pcap export, flow analysis, service mapping (6 tools). Use when capturing Kubernetes pod traffic, debugging service-to-service latency, exporting pcaps from a cluster, or analyzing encrypted east-west traffic"
4license: Apache-2.0
5user-invocable: true
6metadata:
7 { "openclaw": { "requires": { "bins": ["kubectl"], "env": ["KUBESHARK_MCP_URL"] } } }
8---
9
10# Kubeshark Kubernetes Traffic Analysis
11
12## MCP Server
13
14| Property | Value |
15|----------|-------|
16| **Source** | [kubeshark/kubeshark](https://github.com/kubeshark/kubeshark) — [MCP docs](https://docs.kubeshark.com/en/mcp) |
17| **Transport** | Remote HTTP (JSON-RPC 2.0, default port 8898) |
18| **Language** | Go (built into Kubeshark Hub) |
19| **Tools** | 6 (capture, export pcap, snapshot, filter, L4 flows, flow summary) |
20| **Auth** | None (cluster-internal); requires `kubectl port-forward` for remote access |
21| **Requires** | Kubernetes cluster with Kubeshark installed via Helm |
22
23## How to Run
24
25```bash
26# Install Kubeshark with MCP enabled
27helm install kubeshark kubeshark/kubeshark \
28 --set mcp.enabled=true \
29 --set mcp.port=8898
30
31# Port-forward for local access (if not in-cluster)
32kubectl port-forward svc/kubeshark-hub 8898:8898
33
34# MCP endpoint is now available at:
35# http://localhost:8898/mcp
36```
37
38## Environment Variables
39
40| Variable | Required | Example | Description |
41|----------|----------|---------|-------------|
42| `KUBESHARK_MCP_URL` | Yes | `http://localhost:8898/mcp` | Kubeshark MCP endpoint URL |
43| `KUBESHARK_MCP_PORT` | No | `8898` | MCP server port (default: 8898) |
44
45## Tools
46
47| Tool | Parameters | What It Does |
48|------|-----------|-------------|
49| `capture_traffic` | `filter?`, `duration?` | Start targeted packet capture across cluster pods |
50| `export_pcap` | `filter?`, `time_range?` | Export captured traffic as pcap for Wireshark/tshark analysis |
51| `create_snapshot` | `filter?` | Create point-in-time traffic snapshot within retention window |
52| `apply_filter` | `kfl_expression` | Apply Kubeshark Filter Language (KFL) expressions to narrow results |
53| `list_l4_flows` | `filter?` | List TCP/UDP flows with connection stats, RTT metrics, byte counts |
54| `get_l4_flow_summary` | `filter?` | High-level summary: top talkers, protocol distribution, traffic volume |
55
56## Resources Exposed
57
58- Real-time L7 API streams (HTTP, gRPC, GraphQL, Redis, Kafka, DNS) with full request/response payloads
59- Historical traffic queries within the configured retention window
60- Decrypted TLS/HTTPS traffic via eBPF (no manual key management)
61- TCP/UDP connection flows with timing, RTT, and byte statistics
62- Kubernetes pod identity and service mapping (source → destination with namespace/labels)
63
64---
65
66## Workflow: Kubernetes Service Troubleshooting
67
68When investigating connectivity or latency issues between Kubernetes services:
69
701. **Capture traffic**: `capture_traffic(filter="src.pod.name == 'frontend'")` — start targeted capture
712. **List flows**: `list_l4_flows` — see all TCP/UDP connections with RTT and stats
723. **Flow summary**: `get_l4_flow_summary` — identify top talkers and protocol breakdown
734. **Apply filter**: `apply_filter(kfl_expression="response.status >= 500")` — isolate errors
745. **Export pcap**: `export_pcap(filter="dst.pod.name == 'api-gateway'")` — export for deep analysis
756. **Cross-reference**: Use `packet-analysis` skill to analyze exported pcap with tshark
767. **Report**: Service communication analysis with latency, error rates, and traffic patterns
778. **GAIT**: Record all captures and findings in audit trail
78
79### Example: API Gateway Latency Investigation
80
81```
82capture_traffic(filter="dst.pod.name == 'api-gateway'", duration="5m")
83list_l4_flows(filter="dst.pod.name == 'api-gateway'")
84get_l4_flow_summary(filter="dst.pod.name == 'api-gateway'")
85apply_filter(kfl_expression="response.latency > 500ms")
86export_pcap(filter="response.latency > 500ms")
87```
88
89## Workflow: TLS Traffic Inspection
90
91When investigating encrypted service-to-service communication:
92
931. **Capture**: `capture_traffic` — Kubeshark automatically decrypts TLS via eBPF
942. **Filter**: `apply_filter(kfl_expression="request.headers['content-type'] == 'application/grpc'")` — isolate gRPC
953. **Flows**: `list_l4_flows` — see encrypted connections with decrypted payload summaries
964. **Export**: `export_pcap` — export decrypted traffic for offline analysis
975. **Report**: TLS communication audit with certificate info and payload analysis
98
99## Workflow: Incident Traffic Forensics
100
101When performing post-incident traffic analysis:
102
1031. **Snapshot**: `create_snapshot` — capture current traffic state
1042. **Historical query**: `apply_filter` with time range — find traffic around incident time
1053. **Flow analysis**: `list_l4_flows` — identify unusual connections or traffic spikes
1064. **Top talkers**: `get_l4_flow_summary` — find services with abnormal traffic volume
1075. **Export evidence**: `export_pcap` — preserve traffic for incident report
1086. **Cross-reference**: Correlate with Prometheus metrics, Grafana alerts, and pyATS device state
109
110---
111
112## Integration with Other Skills
113
114| Skill | Integration |
115|-------|-------------|
116| **packet-analysis** | Export Kubeshark pcaps → analyze with Packet Buddy tshark (deeper protocol dissection) |
117| **prometheus-monitoring** | Correlate Kubeshark flow metrics with Prometheus time-series data |
118| **grafana-observability** | Cross-reference Kubeshark traffic patterns with Grafana dashboards and alerts |
119| **pyats-health-check** | Compare Kubernetes network traffic with underlying infrastructure health |
120| **gait-session-tracking** | Record all Kubeshark captures, exports, and analysis in GAIT audit trail |
121| **servicenow-change-workflow** | Reference Kubeshark traffic captures as evidence in change requests or incidents |
122
123---
124
125## Kubeshark Filter Language (KFL) Examples
126
127```
128# Filter by pod name
129src.pod.name == "frontend"
130
131# Filter by namespace
132dst.namespace == "production"
133
134# HTTP status codes
135response.status >= 400
136
137# Latency threshold
138response.latency > 200ms
139
140# Protocol type
141protocol == "grpc"
142
143# Combined filters
144src.namespace == "default" and response.status >= 500 and response.latency > 1s
145
146# DNS queries
147protocol == "dns" and request.query contains "api.internal"
148
149# Kafka messages
150protocol == "kafka" and request.topic == "orders"
151```
152
153---
154
155## Important Rules
156
157- **All tools are read-only** — Kubeshark captures and analyzes traffic but does not modify it
158- **Cluster access required** — Kubeshark must be deployed in the target Kubernetes cluster via Helm
159- **Port-forward for remote access** — use `kubectl port-forward svc/kubeshark-hub 8898:8898` when not in-cluster
160- **Retention window** — historical queries are limited to the configured retention period
161- **Large captures** — use KFL filters to scope captures and avoid overwhelming context with large traffic volumes
162- **Sensitive data** — captured traffic may contain PII, credentials, or secrets in request/response payloads; handle exports accordingly
163- **GAIT audit mandatory** — record all traffic captures, pcap exports, and analysis findings
164- **No secrets in filters** — never embed credentials or sensitive data in KFL expressions
165
166## Error Handling
167
168- **Connection refused**: Verify Kubeshark is running (`kubectl get pods -n kubeshark`) and port-forward is active.
169- **No traffic captured**: Check KFL filter syntax; verify target pods exist and are generating traffic.
170- **MCP endpoint not found**: Ensure `mcp.enabled=true` in Helm values; verify MCP port matches `KUBESHARK_MCP_URL`.
171- **Permission denied**: Check RBAC — Kubeshark needs cluster-wide read access for traffic capture.
172- **Empty pcap exports**: Verify retention window covers the requested time range; check that traffic matching the filter exists.