Skip to main content
Glama
CupOfOwls

Kroger MCP Server

get_preferred_location

Retrieve the currently selected Kroger store location for grocery shopping, enabling personalized product searches and cart management.

Instructions

    Get the currently set preferred store location.
    
    Returns:
        Dictionary containing the preferred location information
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_preferred_location' tool. It retrieves the preferred location ID using a helper, fetches details via the Kroger API client, and returns formatted location information or an error.
    @mcp.tool()
    async def get_preferred_location(ctx: Context = None) -> Dict[str, Any]:
        """
        Get the currently set preferred store location.
        
        Returns:
            Dictionary containing the preferred location information
        """
        preferred_location_id = get_preferred_location_id()
        
        if not preferred_location_id:
            return {
                "success": False,
                "message": "No preferred location set. Use set_preferred_location to set one."
            }
        
        if ctx:
            await ctx.info(f"Getting preferred location details for {preferred_location_id}")
        
        # Get location details
        client = get_client_credentials_client()
        
        try:
            location_details = client.location.get_location(preferred_location_id)
            loc_data = location_details.get("data", {})
            
            return {
                "success": True,
                "preferred_location_id": preferred_location_id,
                "location_details": {
                    "name": loc_data.get("name"),
                    "chain": loc_data.get("chain"),
                    "phone": loc_data.get("phone"),
                    "address": loc_data.get("address", {})
                }
            }
            
        except Exception as e:
            if ctx:
                await ctx.error(f"Error getting preferred location details: {str(e)}")
            return {
                "success": False,
                "error": str(e),
                "preferred_location_id": preferred_location_id
            }
  • Registration of the location_tools module, which includes the get_preferred_location tool via its register_tools function.
    location_tools.register_tools(mcp)
  • Helper function that loads and returns the stored preferred location ID from the preferences JSON file, used by the get_preferred_location handler.
    def get_preferred_location_id() -> Optional[str]:
        """Get the current preferred location ID from preferences file"""
        preferences = _load_preferences()
        return preferences.get("preferred_location_id")
  • Companion helper function to store the preferred location ID to the preferences file, referenced in related tools.
    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)
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It states the tool returns a dictionary with location information, which is helpful, but lacks critical details: it doesn't specify if this requires authentication, mention error conditions (e.g., if no location is set), or describe the dictionary's structure. For a tool with zero annotation coverage, this is insufficient.

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

Conciseness4/5

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

The description is concise and well-structured: the first sentence states the purpose clearly, and the second sentence explains the return value. There's no unnecessary information, and it's front-loaded with the core functionality. Minor deduction for the slightly verbose 'Returns:' label instead of integrating it more seamlessly.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but has gaps. It explains what the tool does and the return type, but without annotations, it should ideally mention authentication needs or error handling. It's minimally viable but could be more complete for safe agent use.

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 tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to explain parameters, so it naturally meets expectations. A baseline of 4 is appropriate as it avoids redundancy while focusing on the tool's function.

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: 'Get the currently set preferred store location.' It uses a specific verb ('Get') and identifies the resource ('preferred store location'), making the function unambiguous. However, it doesn't explicitly differentiate from siblings like 'get_location_details' or 'search_locations', which prevents a perfect score.

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), compare it to sibling tools like 'get_location_details' or 'set_preferred_location', or specify use cases. This leaves the agent without contextual direction for tool selection.

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