site_from_url
Retrieve DevHub site details by extracting site ID, URL, and location IDs from a specified URL. Simplifies integration with DevHub CMS tools for content management.
Instructions
Get the DevHub site ID from a URL.
Can prompt the user for the URL instead of passing a site_id.
Returns details about the Site matches the URL that can be used in the other tools.
- Site ID: ID of the DevHub site
- Site URL: URL of the DevHub site
- Site Location IDs: List of location IDs associated with the site
Args:
url: URL of the DevHub site, all lowercase and ends with a slash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
Implementation Reference
- src/devhub_cms_mcp/server.py:145-178 (handler)The handler function for the 'site_from_url' tool, decorated with @mcp.tool() for registration. It parses the URL, queries the DevHub API for matching sites, and returns site details including ID, URL, and location IDs.@mcp.tool() def site_from_url(url: str) -> str: """Get the DevHub site ID from a URL. Can prompt the user for the URL instead of passing a site_id. Returns details about the Site matches the URL that can be used in the other tools. - Site ID: ID of the DevHub site - Site URL: URL of the DevHub site - Site Location IDs: List of location IDs associated with the site Args: url: URL of the DevHub site, all lowercase and ends with a slash """ parsed_url = urlparse(url) subdomain = parsed_url.netloc.split('.', 1)[0] or 'www' domain = parsed_url.netloc.split('.', 1)[1] base_directory = parsed_url.path client, base_url = get_client() r = client.get('{}sites/'.format(base_url), params={ 'base_directory': base_directory, 'deleted': 0, 'domain': domain, 'subdomain': subdomain, }) content = json.loads(r.content) if len(content['objects']) == 0: return 'No site found' site = content['objects'][0] return f""" Site ID: {site['id']} Site URL: {site['formatted_url']} Site Location IDs: {", ".join([str(location_id) for location_id in site['location_ids']])} """