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