Skip to main content

Discovery Configuration

Configure MCP Discovery to automatically find and register MCP servers.

Overview

MCP Discovery is a scanner daemon that:

  1. Discovers MCP servers in your environment
  2. Registers them with the MCP Registry
  3. Monitors their health status
  4. Updates the registry when servers change

Configuration File

Create a config.toml file:

[registry]
url = "http://localhost:8080"
agent_id = "scanner-001"
api_key = "your-api-key"

[scanner]
# Scan interval in seconds
interval = 300

# Discovery methods to enable
methods = ["filesystem", "network", "claude_config"]

[filesystem]
# Paths to scan for MCP server configurations
paths = [
"~/.config/mcp",
"/etc/mcp/servers",
"./mcp-servers"
]

# File patterns to match
patterns = ["*.json", "*.toml", "mcp.config.*"]

[network]
# Network ranges to scan (optional)
enabled = false
ranges = ["192.168.1.0/24"]
ports = [3000, 8080, 9000]

[claude_config]
# Scan Claude Desktop/Code configuration
enabled = true
paths = [
"~/.config/claude/claude_desktop_config.json",
"~/Library/Application Support/Claude/claude_desktop_config.json"
]

Running the Scanner

Single Scan

wl-discover --config config.toml scan

Daemon Mode

wl-discover --config config.toml run

With Custom Config Path

wl-discover --config /path/to/config.toml run

Discovery Methods

Filesystem Discovery

Scans local directories for MCP server configuration files:

[filesystem]
paths = [
"~/.config/mcp",
"/opt/mcp-servers",
"./servers"
]
patterns = ["*.json", "mcp-config.*"]

Expected file format:

{
"name": "my-mcp-server",
"command": "node",
"args": ["./server.js"],
"env": {
"API_KEY": "${MCP_API_KEY}"
}
}

Claude Configuration Discovery

Reads MCP server configs from Claude Desktop/Code:

[claude_config]
enabled = true
paths = [
"~/.config/claude/claude_desktop_config.json",
"~/Library/Application Support/Claude/claude_desktop_config.json"
]

Claude config format:

{
"mcpServers": {
"web-search": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-server-web-search"]
},
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-server-filesystem", "/path/to/files"]
}
}
}

Network Discovery

Scans network for MCP servers (requires explicit enablement):

[network]
enabled = true
ranges = ["10.0.0.0/24"]
ports = [3000, 8080]
timeout_ms = 5000

Environment Variables

Override config values with environment variables:

export REGISTRY_URL=https://registry.example.com
export AGENT_ID=production-scanner
export API_KEY=secret-key

wl-discover --config config.toml run

Scanner Registration

Before running discovery, register the scanner with the registry:

# Using the seed script
./scripts/seed_scanner.sh "Production Scanner" "your-api-key"

# Or via API
curl -X POST http://localhost:8080/scanners \
-H "Content-Type: application/json" \
-d '{
"agent_id": "scanner-001",
"name": "Production Scanner",
"api_key": "your-api-key"
}'

Output and Logging

Log Levels

# Debug output
LOG_LEVEL=debug wl-discover --config config.toml scan

# Quiet mode
LOG_LEVEL=warn wl-discover --config config.toml run

Scan Output

[INFO] Starting MCP Discovery scan
[INFO] Scanning filesystem paths...
[INFO] Found: ~/.config/mcp/web-search.json
[INFO] Found: ~/.config/mcp/filesystem.json
[INFO] Scanning Claude config...
[INFO] Found 3 servers in claude_desktop_config.json
[INFO] Registering 5 servers with registry...
[INFO] Registered: web-search (new)
[INFO] Updated: filesystem (capabilities changed)
[INFO] Skipped: slack (already current)
[INFO] Scan complete: 5 servers found, 2 updated

Health Monitoring

The scanner periodically verifies registered servers:

[scanner]
interval = 300 # Main scan interval
health_check_interval = 60 # Health check interval

[health]
timeout_ms = 5000
retry_count = 3
mark_unhealthy_after = 3 # Consecutive failures

Systemd Service

Run as a system service:

# /etc/systemd/system/mcp-discovery.service
[Unit]
Description=MCP Discovery Scanner
After=network.target

[Service]
Type=simple
User=mcp
WorkingDirectory=/opt/mcp-discovery
ExecStart=/opt/mcp-discovery/mcp-discover --config /etc/mcp/discovery.toml run
Restart=always
RestartSec=10

Environment=LOG_LEVEL=info
Environment=REGISTRY_URL=http://localhost:8080
Environment=API_KEY=your-secret-key

[Install]
WantedBy=multi-user.target
sudo systemctl enable mcp-discovery
sudo systemctl start mcp-discovery

Troubleshooting

Scanner Not Registering Servers

  1. Check registry connectivity:

    curl http://localhost:8080/health
  2. Verify API key:

    curl -H "X-API-Key: your-key" http://localhost:8080/scanners
  3. Check scanner logs:

    LOG_LEVEL=debug wl-discover --config config.toml scan

Servers Not Being Discovered

  1. Verify paths exist and are readable
  2. Check file patterns match your config files
  3. Ensure config files are valid JSON/TOML

Network Discovery Issues

  1. Verify network range is correct
  2. Check firewall rules allow scanning
  3. Increase timeout for slow networks

Next Steps