Troubleshooting Guide
This guide helps you diagnose and resolve common issues when using the MCP Registry Client.
Installation Issues
Python Version Compatibility
Problem: ImportError or syntax errors when importing the client.
Solution: Ensure you're using Python 3.12 or later:
If you need to upgrade Python, consider using pyenv or uv:
# Using uv
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.12
# Using pyenv
pyenv install 3.12.0
pyenv global 3.12.0
Missing Dependencies
Problem: ModuleNotFoundError for httpx or pydantic.
Solution: Install with all dependencies:
For development dependencies:
Network Issues
Connection Refused
Problem: ConnectError when trying to reach the registry.
Symptoms:
Solutions:
- Check internet connection:
- Verify DNS resolution:
- Check firewall/proxy settings:
# Use custom proxy
from mcp_registry_client import RegistryClient
async with RegistryClient() as client:
client._client.proxies = {
"https://": "http://proxy.company.com:8080"
}
SSL/TLS Issues
Problem: SSL verification errors.
Symptoms:
Solutions:
- Update certificates:
# On macOS
/Applications/Python\ 3.x/Install\ Certificates.command
# On Ubuntu/Debian
sudo apt-get update && sudo apt-get install ca-certificates
-
Check system time: Ensure your system clock is correct.
-
Corporate network: Configure certificates for corporate networks:
import httpx
from mcp_registry_client import RegistryClient
# Custom client with cert bundle
async with RegistryClient() as client:
client._client.verify = "/path/to/corporate-ca-bundle.pem"
Timeout Issues
Problem: Requests timing out.
Symptoms:
Solutions:
- Increase timeout:
from mcp_registry_client import RegistryClient
# Increase timeout to 60 seconds
async with RegistryClient(timeout=60.0) as client:
result = await client.search_servers()
- Check network stability:
- Use retry logic (see Error Handling).
API Issues
Rate Limiting
Problem: HTTP 429 (Too Many Requests) errors.
Symptoms:
Solutions:
- Implement backoff:
import asyncio
from mcp_registry_client import RegistryAPIError
async def search_with_backoff(client, **kwargs):
for delay in [1, 2, 4, 8]:
try:
return await client.search_servers(**kwargs)
except RegistryAPIError as e:
if e.status_code == 429:
await asyncio.sleep(delay)
else:
raise
raise # Final attempt failed
-
Reduce request frequency: Add delays between requests.
-
Cache results: Store responses to avoid repeated requests.
Server Not Found
Problem: Getting 404 errors for servers you expect to exist.
Solutions:
- Check server name format:
# Correct format includes namespace
mcp-registry info "ai.waystation/gmail"
# Not just the server name
mcp-registry info gmail
- Search first to find exact name:
- Check if server was recently added: The registry may not be immediately updated.
Invalid Response Format
Problem: ValidationError when processing responses.
Symptoms:
Solutions:
-
Check registry status: The API might be returning unexpected data.
-
Update client: Ensure you're using the latest version:
- Report the issue: If the error persists, it might be an API change.
CLI Issues
Command Not Found
Problem: mcp-registry: command not found
Solutions:
- Check installation:
- Check PATH: Ensure pip's bin directory is in your PATH:
- Use module syntax:
JSON Output Issues
Problem: Malformed JSON output or encoding errors.
Solutions:
- Check terminal encoding:
- Redirect to file:
- Use Python API for programmatic access instead of parsing CLI output.
Performance Issues
Slow Responses
Problem: Requests taking too long to complete.
Solutions:
- Use connection pooling:
import httpx
from mcp_registry_client import RegistryClient
# Reuse client instance
client = RegistryClient()
async with client:
# Multiple requests reuse connections
result1 = await client.search_servers(name="server1")
result2 = await client.search_servers(name="server2")
- Implement caching:
from functools import lru_cache
import asyncio
@lru_cache(maxsize=128)
def _cache_key(name):
return name
_cache = {}
async def cached_search(client, name=None):
key = _cache_key(name)
if key not in _cache:
_cache[key] = await client.search_servers(name=name)
return _cache[key]
- Use specific searches: Search with name filters to reduce response size.
Memory Usage
Problem: High memory usage with large result sets.
Solutions:
- Process results in chunks:
async def process_servers_chunked(client):
result = await client.search_servers()
for server in result.servers:
# Process one server at a time
await process_single_server(server)
# Explicit cleanup if needed
del server
-
Use generators when possible.
-
Limit result sets with specific search criteria.
Development Issues
Testing
Problem: Tests failing due to network dependencies.
Solutions:
- Use httpx mock:
import pytest
import httpx
from mcp_registry_client import RegistryClient
@pytest.mark.asyncio
async def test_search_with_mock(httpx_mock):
httpx_mock.add_response(
method="GET",
url="https://registry.modelcontextprotocol.io/v0/servers",
json={"servers": [], "total": 0}
)
async with RegistryClient() as client:
result = await client.search_servers()
assert result.total == 0
-
Use pytest fixtures for common test data.
-
Test error conditions separately from happy path tests.
Type Checking
Problem: mypy errors with the client.
Solutions:
- Update type hints:
from typing import Optional
from mcp_registry_client import RegistryClient, Server
async def get_server_info(name: str) -> Optional[Server]:
async with RegistryClient() as client:
return await client.get_server_by_name(name)
- Use proper imports:
# Good
from mcp_registry_client import RegistryClient
# Avoid
import mcp_registry_client
client = mcp_registry_client.RegistryClient()
Getting Help
If you're still experiencing issues:
- Check the logs: Enable debug logging:
-
Review error handling: See the Error Handling Guide.
-
Check for updates: Ensure you're using the latest version.
-
Report bugs: Create an issue with:
- Python version
- Client version
- Full error traceback
- Minimal reproduction code
Common Environment Variables
Set these environment variables to customize behavior: