get_nearest_location
Identify the closest DevHub CMS location using a business ID, latitude, and longitude for efficient location-based management and content administration.
Instructions
Get the nearest DevHub location
Args:
business_id: DevHub Business ID associated with the location. Prompt the user for this ID
latitude: Latitude of the location
longitude: Longitude of the location
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| business_id | Yes | ||
| latitude | Yes | ||
| longitude | Yes |
Implementation Reference
- src/devhub_cms_mcp/server.py:290-317 (handler)The handler function for the 'get_nearest_location' MCP tool. It uses the DevHub API to find the nearest location to given coordinates for a business. The @mcp.tool() decorator registers it and the function signature/docstring provides the schema.@mcp.tool() def get_nearest_location(business_id: int, latitude: float, longitude: float) -> str: """Get the nearest DevHub location Args: business_id: DevHub Business ID associated with the location. Prompt the user for this ID latitude: Latitude of the location longitude: Longitude of the location """ client, base_url = get_client() r = client.get('{}locations/'.format(base_url), params={ 'business_id': business_id, 'near_lat': latitude, 'near_lon': longitude, }) objects = json.loads(r.content)['objects'] if objects: return f""" Location ID: {objects[0]['id']} Location name: {objects[0]['location_name']} Location url: {objects[0]['location_url']} Street: {objects[0]['street']} City: {objects[0]['city']} State: {objects[0]['state']} Country: {objects[0]['country']} """
- src/devhub_cms_mcp/server.py:15-22 (helper)Helper function used by get_nearest_location (and other tools) to initialize the OAuth client and base URL for API requests.def get_client(): """Get DevHub API client and base_url.""" client = OAuth1Session( os.environ['DEVHUB_API_KEY'], client_secret=os.environ['DEVHUB_API_SECRET']) base_url = '{}/api/v2/'.format(os.environ['DEVHUB_BASE_URL']) return client, base_url
- src/devhub_cms_mcp/server.py:290-290 (registration)The @mcp.tool() decorator registers the get_nearest_location function as an MCP tool.@mcp.tool()