Skip to content

Claude Code Integration

Herve Hildenbrand edited this page Apr 8, 2026 · 7 revisions

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.

Overview

┌─────────────────────────────────────────────────────────────┐
│                     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.

Setup

1. Install BGP Explorer Globally

git clone https://github.com/hervehildenbrand/bgp-explorer.git
cd bgp-explorer
uv sync
uv run bgp-explorer install-deps  # Installs monocle and bgp-radar
uv tool install .                  # Installs bgp-explorer globally

The uv tool install . command makes bgp-explorer available system-wide, so it works from any directory.

2. Add to Claude Code

claude mcp add bgp-explorer -- bgp-explorer mcp

3. Verify Installation

claude mcp list

# Should show:
# bgp-explorer: bgp-explorer mcp - ✓ Connected

4. Use Claude Code

claude

Now 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?

Available Tools (8 composite)

The MCP server exposes 8 composite tools. Each returns a summary by default with a sections parameter for detail:

Tool Purpose Sections
search_asn Find ASNs by name
investigate_asn ASN investigation summary, connectivity, announcements, contacts, resilience, whois
investigate_prefix Prefix investigation summary, routing, anomalies, paths, collectors, looking_glass
check_rpki RPKI/ROA/ASPA summary, roa_coverage, roa_guidance, aspa_status, aspa_guidance, rov_coverage
get_routing_history_v2 History + stability summary, origins, paths, stability, updates
investigate_ixp IXP presence/details Auto-detects: ASN → presence, name → details
probe_network Ping/traceroute type: ping or traceroute
run_audit Compliance audits framework: dora, nis2, manrs, all

See Tools Reference for full documentation.

Example Queries

Finding an ASN

> Search for Google's ASNs

Claude will use search_asn to find AS15169 and related ASNs.

Investigating a Prefix

> 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

Network Connectivity

> 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

Global Reachability

> 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.

Managing the MCP Server

List MCP Servers

claude mcp list

Remove bgp-explorer

claude mcp remove bgp-explorer

Check Server Status

When in Claude Code, type /mcp to see connected MCP servers and their status.

Troubleshooting

"Failed to reconnect to bgp-explorer" or "command not found"

This is the most common issue. It means bgp-explorer is not installed globally.

Fix: Install globally with uv tool install:

# Go to your bgp-explorer clone
cd /path/to/bgp-explorer

# Install globally
uv tool install .

# Remove broken config and re-add
claude mcp remove bgp-explorer 2>/dev/null
claude mcp add bgp-explorer -- bgp-explorer mcp

# Verify it works
claude mcp list

After uv tool install ., the bgp-explorer command works from anywhere on your system.

"Monocle is not configured"

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

Tools Not Appearing

  1. Check the MCP server is added and connected:

    claude mcp list
    # Should show: bgp-explorer: ... - ✓ Connected
  2. If it shows "Not connected" or error, re-add with correct path (see above)

  3. Restart Claude Code after fixing the configuration

  4. Test the MCP server manually:

    cd /path/to/bgp-explorer
    uv run bgp-explorer mcp --help

Slow Responses

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.

Comparison: MCP Server vs Standalone Mode

Feature MCP Server (bgp-explorer mcp) Standalone (bgp-explorer chat)
AI Processing Claude Code subscription Anthropic API key
Tools Available 8 composite (no real-time monitoring) Individual tools (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.

Clone this wiki locally