Skip to main content
Glama
CupOfOwls

Kroger MCP Server

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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a write operation ('Set'), implying mutation, but doesn't disclose permissions needed, whether the change is persistent, error conditions, or side effects. It mentions a return value but provides no details on format or potential errors.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence adds value: the first states the tool's function, and the subsequent lines provide essential parameter and return information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain authentication requirements, error handling, persistence of the setting, or how this interacts with other operations. The return value mention is vague ('Dictionary confirming...') without specifics.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'location_id', explaining it's 'the unique identifier for the store location'. With 0% schema description coverage, this compensates well by clarifying the parameter's purpose beyond the schema's basic type information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Set') and resource ('preferred store location'), and it distinguishes from the sibling 'get_preferred_location' by indicating this is a write operation. However, it doesn't explicitly differentiate from other location-related tools like 'search_locations' or 'check_location_exists'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication status), when not to use it, or how it relates to sibling tools like 'get_preferred_location' or 'search_locations'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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