Error types
All errors are handled by the_call wrapper function in server.py:86-120, which catches exceptions from the Stobo client and returns structured JSON responses.
AuthError
Raised when authentication fails due to missing, invalid, or expired API keys. Status codes:401, 403
Common scenarios:
No API key configured
No API key configured
When Resolution:
STOBO_API_KEY is not set and a paid tool is called:- Sign up at trystobo.com
- Generate an API key from Settings > API Keys
- Add to your MCP config’s
envsection - Restart your editor
Invalid or expired key
Invalid or expired key
When an API key is configured but invalid:Resolution:
- Log in to trystobo.com
- Revoke the old key
- Generate a new API key
- Update your MCP config
- Restart your editor
RateLimitError
Raised when you exceed the API rate limits. Status code:429
Response format:
Rate limiting is applied per API key. Free tools without authentication have separate, more generous limits.
StoboAPIError
Generic API error for various failure scenarios. Status codes: Various (most commonly402, 400, 404, 500)
Payment required (402)
Payment required (402)
When you’ve exhausted your credit balance:Affected tools:
generate_llms_txt(500 credits)extract_tone(500 credits)rewrite_article(1,000 credits)
- Top up credits at trystobo.com
- Free tools continue working without credits
- Use
get_creditsto check your balance
Generic API errors
Generic API errors
For all other API errors (validation, not found, server errors):The
error field contains the specific error message from the Stobo API’s detail field.Generic exceptions
Catches any unexpected errors not covered by specific error types. Response format:Error handling patterns
In tool implementations
All tools use the_call wrapper to ensure consistent error handling:
_call function:
- Executes the client method
- Serializes the result to JSON
- Catches and transforms exceptions into user-friendly error messages
- Returns structured JSON with error details and status codes
Connection diagnostics
Thecheck_connection tool provides detailed diagnostics for connectivity issues:
base_url— The API endpoint being usedhas_api_key— Whether an API key is configuredstatus— Connection status (ok,error,connection_refused,timeout)http_code— HTTP status code (if connection succeeded)error— Error message (if any)fix— Suggested resolution (for known issues)
Best practices
- Check connection first — Use
check_connectionto diagnose setup issues before running audits - Monitor credits — Call
get_creditsperiodically to avoid unexpected402errors - Handle rate limits gracefully — Implement retry logic with exponential backoff for
429errors - Validate API keys — Test with a free tool first, then verify paid tools work
- Parse error responses — All errors return structured JSON with
errorandstatus_codefields
Debugging
To debug issues:- Run
check_connectionto verify basic connectivity - Check the
status_codefield to identify the error type:401/403→ Authentication issue429→ Rate limiting402→ Out of credits400→ Invalid request404→ Resource not found500→ Server error
- Review the
errormessage for specific details - Verify environment variables are set correctly
- Ensure you’re using the latest version of
stobo-mcp