Skip to main content
Glama

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

Implementation Reference

  • 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']} """
  • 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
  • The @mcp.tool() decorator registers the get_nearest_location function as an MCP tool.
    @mcp.tool()

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