Show HN: I made an MCP Server for Whois and RDAP

4 months ago 4

A modern, high-performance Model Context Protocol (MCP) server providing domain and IP address lookup services using both traditional Whois and modern RDAP protocols.

Modern Architecture: Clean package structure with uv for dependency management
🚀 High Performance: Asynchronous operations with connection pooling
🛡️ Rate Limiting: Built-in protection for external registry servers
💾 Smart Caching: In-memory LRU cache with TTL for optimal performance
🔍 Dual Protocols: Support for both Whois (TCP) and RDAP (HTTPS) lookups
🌍 Global Coverage: Comprehensive support for major TLDs and Regional Internet Registries
📊 Structured Logging: Detailed logging with structured output
🧪 Comprehensive Testing: Full test suite with pytest and asyncio support

# Clone the repository git clone <repository-url> cd whoismcp # Install with uv (recommended) uv sync --extra dev # Or install with pip pip install -e ".[dev]"

The MCP server communicates via stdin/stdout as per the MCP specification:

# Using uv (recommended) uv run whoismcp-server # Or directly ./mcp_server_new # For development python -m whoismcp.mcp_server
# Interactive whois lookup uv run whoismcp whois example.com # RDAP lookup with JSON output uv run whoismcp rdap example.com --output json # Test server connectivity uv run whoismcp test-server --host localhost --port 5001

A web interface demonstrates the functionality:

python main.py # Visit http://localhost:5000

Add to your MCP client configuration:

{ "mcpServers": { "whoismcp": { "command": "uv", "args": ["run", "whoismcp-server"], "cwd": "/path/to/whoismcp" } } }
  • whois_lookup: Perform Whois lookup for domain or IP address
  • rdap_lookup: Perform RDAP lookup for domain or IP address
  • whois://domain/{domain} - Domain Whois information
  • whois://ip/{ip} - IP Whois information
  • rdap://domain/{domain} - Domain RDAP information
  • rdap://ip/{ip} - IP RDAP information
whoismcp/ ├── src/whoismcp/ # Main package │ ├── __init__.py # Package exports │ ├── config.py # Configuration management │ ├── mcp_server.py # MCP server implementation │ ├── cli.py # Command-line interface │ ├── models/ # Data models │ │ ├── __init__.py │ │ └── domain_models.py │ ├── services/ # Core services │ │ ├── __init__.py │ │ ├── whois_service.py │ │ ├── rdap_service.py │ │ └── cache_service.py │ └── utils/ # Utilities │ ├── __init__.py │ ├── validators.py │ ├── parsers.py │ └── rate_limiter.py ├── tests/ # Test suite ├── pyproject.toml # Package configuration └── README.md # This file

Environment variables for customization:

# Server settings BIND_HOST=0.0.0.0 # Bind host (default: 0.0.0.0) BIND_PORT=5001 # Bind port (default: 5001) # Timeouts WHOIS_TIMEOUT=30 # Whois timeout in seconds RDAP_TIMEOUT=30 # RDAP timeout in seconds # Caching CACHE_TTL=3600 # Cache TTL in seconds CACHE_MAX_SIZE=1000 # Maximum cache entries CACHE_CLEANUP_INTERVAL=300 # Cleanup interval in seconds # Rate limiting GLOBAL_RATE_LIMIT_PER_SECOND=10.0 # Global rate limit GLOBAL_RATE_LIMIT_BURST=50 # Global burst limit CLIENT_RATE_LIMIT_PER_SECOND=2.0 # Per-client rate limit CLIENT_RATE_LIMIT_BURST=10 # Per-client burst limit # Logging LOG_LEVEL=INFO # Logging level (DEBUG, INFO, WARNING, ERROR)
# Run all tests uv run pytest # Run with coverage uv run pytest --cov=src/whoismcp --cov-report=html # Run specific test file uv run pytest tests/test_mcp_server.py -v
# Format code uv run black src/ tests/ # Lint code uv run ruff check src/ tests/ # Type checking uv run mypy src/whoismcp/

This project uses uv for modern Python package management:

# Add dependency uv add httpx # Add development dependency uv add --dev pytest # Update dependencies uv sync # Build package uv build
  • JSON-RPC 2.0: Standard protocol over stdin/stdout
  • Initialize: Handshake and capability negotiation
  • Tools: Available lookup functions
  • Resources: URI-based data access
  • Streaming: Real-time request/response handling
  • WhoisService: Asynchronous TCP connections to global Whois servers
  • RDAPService: HTTPS requests to structured RDAP endpoints with bootstrap discovery
  • CacheService: In-memory LRU cache with TTL for performance optimization
  • RateLimiter: Token bucket implementation with per-client and global limits
  1. Request Processing: MCP client sends JSON-RPC request via stdin
  2. Validation: Input validation for domain/IP format
  3. Rate Limiting: Enforce per-client and global rate limits
  4. Cache Check: Attempt to serve from cache if available
  5. Service Dispatch: Route to appropriate service (Whois/RDAP)
  6. Data Retrieval: Query external servers with connection pooling
  7. Response Parsing: Parse and structure response data
  8. Caching: Store successful results for future requests
  9. Response: Return structured JSON-RPC response via stdout
  • Generic TLDs: .com, .net, .org, .info, .biz, and more
  • Country TLDs: .uk, .de, .fr, .nl, .au, .ca, .jp, and more
  • Regional Internet Registries: ARIN, RIPE, APNIC, LACNIC, AFRINIC
  • Bootstrap Discovery: Automatic server discovery via IANA bootstrap
  • Structured Data: Modern JSON-based responses
  • Standardized Format: Consistent data structure across registries
  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes with tests
  4. Run the test suite: uv run pytest
  5. Check code quality: uv run black . && uv run ruff check .
  6. Submit a pull request

This project is licensed under the MIT License - see the LICENSE file for details.

Read Entire Article