sitebay_list_sites
Retrieve a list of WordPress sites managed by the authenticated user, displaying domain, status, region, and version details. Filter results by team ID to organize sites efficiently.
Instructions
List all WordPress sites for the authenticated user.
Args: team_id: Optional team ID (UUID4) to filter sites by team
Returns: Formatted string with site details including domain, status, region, and versions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team_id | No |
Implementation Reference
- src/sitebay_mcp/server.py:49-81 (handler)MCP tool handler registration and execution wrapper for sitebay_list_sites. Initializes the SiteBay client, handles MCP context logging, delegates to the core sites module helper, and manages errors.@mcp.tool async def sitebay_list_sites(ctx: Context, team_id: Optional[UUID4] = None) -> str: """ List all WordPress sites for the authenticated user. Args: team_id: Optional team ID (UUID4) to filter sites by team Returns: Formatted string with site details including domain, status, region, and versions """ try: await ctx.info("Fetching WordPress sites from SiteBay") if team_id: await ctx.info(f"Filtering by team ID: {team_id}") client = await initialize_client() team_id_str = str(team_id) if team_id is not None else None result = await sites.sitebay_list_sites(client, team_id_str) await ctx.info("Successfully retrieved site list") return result except SiteBayError as e: await ctx.error(f"SiteBay API error: {str(e)}") return f"❌ SiteBay Error: {str(e)}" except ValueError as e: await ctx.error(f"Validation error listing sites: {str(e)}") return f"❌ Validation Error: {str(e)}" except Exception as e: await ctx.error(f"Unexpected error listing sites: {str(e)}") return f"❌ Unexpected error: {str(e)}"
- src/sitebay_mcp/tools/sites.py:10-55 (helper)Core helper function implementing the site listing logic: calls client.list_sites, validates and formats the response into a user-friendly string with site details.async def sitebay_list_sites( client: SiteBayClient, team_id: Optional[str] = None ) -> str: """ List all WordPress sites for the authenticated user. Args: team_id: Optional team ID to filter sites by team Returns: Formatted string with site details """ try: # Normalize team_id to string (UUID4 expected by API) if team_id is not None: team_id = str(team_id) sites = await client.list_sites(team_id=team_id) if isinstance(sites, str): return f"Error listing sites: {sites}" if not isinstance(sites, list) or not all(isinstance(s, dict) for s in sites): return f"Unexpected response format when listing sites: {sites}" if not sites: return "No sites found for your account." result = f"Found {len(sites)} site(s):\n\n" for site in sites: result += f"• **{site.get('fqdn', 'Unknown')}**\n" result += f" - Active: {site.get('active', 'Unknown')}\n" result += f" - HTTP Auth Enabled: {site.get('http_auth_enabled', 'Unknown')}\n" result += f" - Is Free: {site.get('is_free', 'Unknown')}\n" result += f" - Created: {site.get('created_at', 'Unknown')}\n" result += "\n" return result except SiteBayError as e: return f"Error listing sites: {str(e)}" except ValueError as e: return f"Error listing sites: {str(e)}"