| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A unified CLI tool that provides MCP (Model Context Protocol) server capabilities for real-time network connectivity analytics with AI-powered insights and OpenAI function calling integration.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ netspy CLI │───▶│ MCP Server │───▶│ eBPF Server │
│ (MCP Client) │ │ (Internal) │ │ (HTTP API) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ OpenAI API │
│ (Function │
│ Calling) │
└─────────────────┘
User Query → Conversation Manager → OpenAI API → Function Calls → MCP Tools → Results → Final Response
eBPF Network Monitor Server: Build from ebpf-server repository
git clone git@github.com:SRodi/ebpf-server.git
cd ebpf-server
make build # Compiles both Go code AND eBPF programsRoot Privileges: Required for eBPF operations on the server
OpenAI API Key: Required for AI insights (set OPENAI_API_KEY environment variable)
export OPENAI_API_KEY=your_openai_api_key_herego build -o netspy ./cmd/netspy# 1. Start the eBPF API server (run once and keep running)
cd /path/to/ebpf-server
sudo ./bin/ebpf-server --http --port 8080
# 2. Set OpenAI API key
export OPENAI_API_KEY=your_key_here
# 3. Generate some network traffic
curl -s http://google.com
# 4. Use contextual analysis
./netspy
netspy-mcp> contextual "analyze my system"The AI-powered analysis automatically selects and chains multiple tools:
# Interactive mode with contextual analysis
./netspy
netspy-mcp> contextual "What's happening with my network connections?"
netspy-mcp> contextual "Are there any packet drops or connection issues?"
netspy-mcp> contextual "Analyze the network behavior of process nginx"
# Command line mode
./netspy --tool contextual_analysis --query "Analyze my network activity"
./netspy --tool contextual_analysis --query "How is curl behaving?" --process curl# Interactive mode
./netspy
netspy-mcp> summary --pid 1234 --duration 120
netspy-mcp> list --process curl --max-events 20
netspy-mcp> analyze --process nginx
netspy-mcp> insights "curl made 5 connections in 60 seconds"
# Single command mode
./netspy --tool get_network_summary --pid 1234 --duration 120
./netspy --tool list_connections --process curl --max-events 15
./netspy --tool analyze_patterns --process ssh### Contextual Analysis
netspy-mcp> contextual "analyze my system"
### Comprehensive Network Analysis
1. **Network Summary**:
- Over the last 60 seconds, there were **10 outbound connection attempts** recorded.
2. **Detailed Connection Events**:
- A total of **29 connection events** were logged recently.
- Notable connections include:
- **10 connections** to `127.0.0.1:8080` by the process `netspy`.
- Additional connections to DNS servers and local processes.
3. **Packet Drops**:
- There have been **3 packet drops** across all processes in the last 60 seconds.
4. **Connection Patterns**:
- **Top Destinations**: Local connections dominate with 8 connections to `:0`
- **Protocols Used**: Predominantly TCP (9 connections) and UDP (12 connections)
### Insights & Recommendations:
- **Monitor `netspy`**: Heavy localhost usage detected
- **Investigate Packet Drops**: Monitor for recurring losses
- **Consider Network Capacity**: Optimize settings if under heavy load
- **Regular Monitoring**: Implement ongoing monitoring for these metricsnetspy-mcp> summary --process curl
Process 'curl' made 5 outbound connection attempts over the last 60 seconds
netspy-mcp> list --max-events 5
Recent connection events (15 total):
21:05:53 | 127.0.0.1:8080 | TCP | netspy
21:03:38 | (local socket) | UNIX | snapd
21:01:08 | (local socket) | UNIX | snapd
20:58:42 | 192.168.120.2:53 | UDP | systemd-resolve
20:56:15 | 172.217.164.78:443 | TCP | curlThe system automatically registers all MCP tools as OpenAI functions, enabling the LLM to:
Each tool accepts these parameters (all optional unless specified):
Network Analysis Functions:
AI Functions:
No Tool Context Integration → Live Tool Access
Missing Function Calling → Full OpenAI Function Support
Static Approach → Dynamic Tool Usage
Limited Context → Structured Context Management
"Connection refused" or failed connection
"No connections found" when server has data
"permission denied"
OpenAI API errors
"open bpf/connection.o: no such file or directory"
import "github.com/srodi/netspy/internal/mcp"
// Create MCP client with embedded server
mcpClient := mcp.NewMCPClient("http://localhost:8080", true)
// Start interactive mode
ctx := context.Background()
err := mcpClient.StartInteractiveMode(ctx)
// Or execute single command
arguments := map[string]any{
"pid": 1234,
"duration": 120,
}
result, err := mcpClient.RunSingleCommand(ctx, "get_network_summary", arguments)import "github.com/srodi/netspy/internal/openai"
// Create contextual network analyst
analyst := openai.NewContextualNetworkAnalyst(mcpExecutor)
// Analyze with natural language
analysis, err := analyst.AnalyzeNetworkQuery(ctx, "What's happening with my network?")
// Process-specific analysis
analysis, err := analyst.AnalyzeProcess(ctx, "nginx", 0, 60)Function Call Manager (internal/openai/functions.go)
Conversation Manager (internal/openai/client.go)
Intelligent Network Analyst (internal/openai/analyst.go)
MCP Server (internal/mcp/server.go)
The architecture supports easy extension for:
This project is part of the network telemetry ecosystem and integrates with the ebpf-server for comprehensive network monitoring capabilities.
| Back | FazBrowse Home | New Git URL |