error handling and graceful degradation for api failures
Implements error handling for Perplexity API failures (rate limits, timeouts, invalid responses) by catching exceptions, mapping them to MCP error codes, and returning structured error responses to the client. The server implements retry logic with exponential backoff for transient failures and provides fallback responses when Perplexity is unavailable. Error messages include diagnostic information (HTTP status, error code, retry-after headers) to help clients decide whether to retry.
Unique: Implements MCP-compliant error responses with diagnostic metadata (retry-after, error codes) rather than raw API errors, allowing clients to make informed retry decisions — the error abstraction layer decouples Perplexity's error semantics from MCP clients
vs alternatives: More resilient than direct API calls because retry logic is built-in; more informative than generic error messages because diagnostic metadata is included