-
Notifications
You must be signed in to change notification settings - Fork 5
Claude Code Integration
BGP Explorer can be used as an MCP (Model Context Protocol) server with Claude Code, allowing you to use BGP investigation tools with your Claude Code subscription (Pro/Max) instead of requiring a separate Anthropic API key.
┌─────────────────────────────────────────────────────────────┐
│ Claude Code (CLI) │
│ │
│ AI Processing: Uses YOUR Claude Code subscription │
│ (Pro/Max credits - NOT a separate API key) │
│ │
└───────────────────────────┬──────────────────────────────────┘
│ MCP Protocol (stdio)
▼
┌─────────────────────────────────────────────────────────────┐
│ bgp-explorer MCP Server │
│ │
│ NO AI here - just data fetching tools: │
│ - RIPE Stat (free API) │
│ - Monocle CLI (free) │
│ - Globalping (free tier) │
│ - PeeringDB cache (free) │
│ │
└─────────────────────────────────────────────────────────────┘
Key point: The MCP server contains zero AI code. All AI reasoning happens in Claude Code using your subscription credits.
git clone https://github.com/hervehildenbrand/bgp-explorer.git
cd bgp-explorer
uv sync
uv run bgp-explorer install-deps # Installs monocle and bgp-radarImportant: You must use the full path to the bgp-explorer directory because the bgp-explorer command is not globally installed.
# Add bgp-explorer as an MCP server (replace with YOUR actual path)
claude mcp add bgp-explorer -- uv run --directory /path/to/bgp-explorer bgp-explorer mcp
# Example paths:
# macOS/Linux:
claude mcp add bgp-explorer -- uv run --directory ~/Code/bgp-explorer bgp-explorer mcp
# Or with absolute path:
claude mcp add bgp-explorer -- uv run --directory /Users/yourname/Code/bgp-explorer bgp-explorer mcpThis tells Claude Code to:
- Change to the bgp-explorer directory
- Run
uv run bgp-explorer mcpwhich starts the MCP server
# Check the MCP server is registered
claude mcp list
# Should show:
# bgp-explorer: uv run --directory /your/path/bgp-explorer bgp-explorer mcp - ✓ ConnectedclaudeNow you can ask BGP-related questions and Claude Code will automatically use the bgp-explorer tools:
> Search for Cloudflare's ASNs
> How many peers does AS13335 have?
> Check if 8.8.8.0/24 is being hijacked
> Ping 1.1.1.1 from Asia
> What IXPs is Google present at?
The MCP server exposes 24 BGP investigation tools with security-first methodology (proactive RPKI checks) and IPv4/IPv6 awareness (separate reporting by address family):
| Tool | Description |
|---|---|
search_asn |
Search for ASNs by organization name |
lookup_prefix |
Get origin ASN, AS paths, visibility for a prefix |
get_asn_announcements |
List all prefixes announced by an ASN |
get_routing_history |
Historical routing data for a resource |
get_rpki_status |
RPKI validation (valid/invalid/not-found) |
analyze_as_path |
Path diversity, transit ASNs, prepending detection |
get_asn_details |
Detailed ASN analysis |
check_prefix_anomalies |
On-demand hijack detection (MOAS, RPKI, origin changes) |
| Tool | Description |
|---|---|
get_as_peers |
Get all peers for an AS |
get_as_upstreams |
Get upstream transit providers |
get_as_downstreams |
Get downstream customers |
check_as_relationship |
Check relationship between two ASes |
get_as_connectivity_summary |
Overview of AS's network position |
| Tool | Description |
|---|---|
ping_from_global |
Ping from worldwide vantage points |
traceroute_from_global |
Traceroute from multiple locations |
| Tool | Description |
|---|---|
get_ixps_for_asn |
Get IXP presence for an ASN |
get_network_contacts |
Get NOC/abuse contacts |
| Tool | Description |
|---|---|
assess_network_resilience |
Score network resilience (1-10) with transit, peering, IXP analysis |
> Search for Google's ASNs
Claude will use search_asn to find AS15169 and related ASNs.
> Is 203.0.113.0/24 being hijacked?
Claude will use check_prefix_anomalies to check for:
- Multiple Origin AS (MOAS)
- RPKI validation status
- Recent origin changes
- Visibility anomalies
> How well connected is Cloudflare?
Claude will use get_as_connectivity_summary to show:
- Total neighbors (upstreams, peers, downstreams)
- Top providers and customers
- Visibility across BGP peers
> Ping 8.8.8.8 from Europe and show latency
Claude will use ping_from_global with location=['Europe'] to run
measurements from European vantage points.
claude mcp listclaude mcp remove bgp-explorerWhen in Claude Code, type /mcp to see connected MCP servers and their status.
This is the most common issue. It means the MCP server command path is wrong.
Cause: The bgp-explorer command is NOT globally installed. It only works via uv run.
Fix: Re-add the MCP server with the correct full path:
# First remove the broken configuration
claude mcp remove bgp-explorer
# Re-add with correct command (use YOUR actual path)
claude mcp add bgp-explorer -- uv run --directory /path/to/bgp-explorer bgp-explorer mcp
# Verify it works
claude mcp listCommon mistakes:
- ❌
bgp-explorer mcp- Won't work (not globally installed) - ❌
uv run bgp-explorer mcp- Won't work (needs directory context) - ✅
uv run --directory /path/to/bgp-explorer bgp-explorer mcp- Correct!
The monocle binary isn't installed or not in PATH:
# Navigate to bgp-explorer directory first
cd /path/to/bgp-explorer
# Install monocle
uv run bgp-explorer install-deps
# Or manually:
cargo install monocle-
Check the MCP server is added and connected:
claude mcp list # Should show: bgp-explorer: ... - ✓ Connected -
If it shows "Not connected" or error, re-add with correct path (see above)
-
Restart Claude Code after fixing the configuration
-
Test the MCP server manually:
cd /path/to/bgp-explorer uv run bgp-explorer mcp --help
Some queries (especially AS connectivity) can take a few seconds because they:
- Query external APIs (RIPE Stat, Globalping)
- Run the monocle CLI
- Process large datasets
This is normal for BGP data analysis.
| Feature | MCP Server (bgp-explorer mcp) |
Standalone (bgp-explorer chat) |
|---|---|---|
| AI Processing | Claude Code subscription | Anthropic API key |
| Tools Available | 18 (no real-time monitoring) | 24 (includes monitoring) |
| Use Case | Quick queries in Claude Code | Dedicated BGP investigation |
| API Costs | Included in Claude Code sub | Per-token API charges |
Note: The MCP server does not include real-time monitoring tools (start_monitoring, stop_monitoring, get_anomalies) because those require a long-running bgp-radar process which doesn't fit the MCP request-response model. Use standalone mode for real-time monitoring.