get_nearest_location
Find the closest DevHub CMS location by providing business ID and coordinates to identify nearby facilities.
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-315 (handler)The main handler function for the 'get_nearest_location' tool. It is decorated with @mcp.tool() which also serves as registration and defines the schema via type hints and docstring. Fetches the nearest location from DevHub API using provided coordinates and business ID.@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-21 (helper)Helper function get_client() used by get_nearest_location to obtain the OAuth client and base URL for API calls.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