Skip to main content
Glama

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
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • 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']])} """

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/devhub/devhub-cms-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server