Skip to main content
Glama

set_preferred_location

Set your preferred Kroger store location to streamline grocery shopping operations like product searches and cart management.

Instructions

Set a preferred store location for future operations. Args: location_id: The unique identifier for the store location Returns: Dictionary confirming the preferred location has been set

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
location_idYes

Implementation Reference

  • The primary handler function for the set_preferred_location MCP tool. Decorated with @mcp.tool() for automatic registration. Validates location existence via Kroger API, fetches details, persists via helper function, and returns formatted response.
    @mcp.tool() async def set_preferred_location( location_id: str, ctx: Context = None ) -> Dict[str, Any]: """ Set a preferred store location for future operations. Args: location_id: The unique identifier for the store location Returns: Dictionary confirming the preferred location has been set """ if ctx: await ctx.info(f"Setting preferred location to {location_id}") # Verify the location exists client = get_client_credentials_client() try: exists = client.location.location_exists(location_id) if not exists: return { "success": False, "error": f"Location {location_id} does not exist" } # Get location details for confirmation location_details = client.location.get_location(location_id) loc_data = location_details.get("data", {}) set_preferred_location_id(location_id) if ctx: await ctx.info(f"Preferred location set to {loc_data.get('name', location_id)}") return { "success": True, "preferred_location_id": location_id, "location_name": loc_data.get("name"), "message": f"Preferred location set to {loc_data.get('name', location_id)}" } except Exception as e: if ctx: await ctx.error(f"Error setting preferred location: {str(e)}") return { "success": False, "error": str(e) }
  • Supporting utility function that persists the preferred location ID to kroger_preferences.json file by loading, updating, and saving the preferences dictionary.
    def set_preferred_location_id(location_id: str) -> None: """Set the preferred location ID in preferences file""" preferences = _load_preferences() preferences["preferred_location_id"] = location_id _save_preferences(preferences)
  • Invocation of the register_tools function from location_tools module, which defines and registers the set_preferred_location tool (along with other location tools) to the FastMCP server instance.
    location_tools.register_tools(mcp)

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/CupOfOwls/kroger-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server