check_location_exists
Verify the existence of a specific store location in Kroger's system by providing its unique identifier. Returns a dictionary confirming the location's status.
Instructions
Check if a location exists in the Kroger system.
Args:
location_id: The unique identifier for the store location
Returns:
Dictionary indicating whether the location exists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location_id | Yes |
Implementation Reference
- The core handler function decorated with @mcp.tool(), implementing the logic to check if a Kroger store location exists using the API client. This defines the tool's input schema via type hints and docstring, and handles execution with error handling.@mcp.tool() async def check_location_exists( location_id: str, ctx: Context = None ) -> Dict[str, Any]: """ Check if a location exists in the Kroger system. Args: location_id: The unique identifier for the store location Returns: Dictionary indicating whether the location exists """ if ctx: await ctx.info(f"Checking if location {location_id} exists") client = get_client_credentials_client() try: exists = client.location.location_exists(location_id) return { "success": True, "location_id": location_id, "exists": exists, "message": f"Location {location_id} {'exists' if exists else 'does not exist'}" } except Exception as e: if ctx: await ctx.error(f"Error checking location existence: {str(e)}") return { "success": False, "error": str(e) }
- src/kroger_mcp/server.py:72-72 (registration)The registration call in the main server setup that invokes location_tools.register_tools(mcp), thereby registering the check_location_exists tool along with other location tools on the FastMCP server instance.location_tools.register_tools(mcp)