Skip to main content
Glama

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
NameRequiredDescriptionDefault
business_idYes
latitudeYes
longitudeYes

Implementation Reference

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

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