Skip to main content
Glama
CupOfOwls

Kroger MCP Server

check_chain_exists

Verify if a specific grocery chain exists in the Kroger system by providing the chain name, returning a confirmation status for store availability checks.

Instructions

    Check if a chain exists in the Kroger system.
    
    Args:
        chain_name: Name of the chain to check
    
    Returns:
        Dictionary indicating whether the chain exists
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_nameYes

Implementation Reference

  • The handler function for the 'check_chain_exists' tool. It takes a chain_name parameter, uses get_client_credentials_client to get the API client, calls client.location.chain_exists(), and returns a success dict with existence status.
    @mcp.tool()
    async def check_chain_exists(
        chain_name: str,
        ctx: Context = None
    ) -> Dict[str, Any]:
        """
        Check if a chain exists in the Kroger system.
        
        Args:
            chain_name: Name of the chain to check
        
        Returns:
            Dictionary indicating whether the chain exists
        """
        if ctx:
            await ctx.info(f"Checking if chain '{chain_name}' exists")
        
        client = get_client_credentials_client()
        
        try:
            exists = client.location.chain_exists(chain_name)
            
            return {
                "success": True,
                "chain_name": chain_name,
                "exists": exists,
                "message": f"Chain '{chain_name}' {'exists' if exists else 'does not exist'}"
            }
            
        except Exception as e:
            if ctx:
                await ctx.error(f"Error checking chain existence: {str(e)}")
            return {
                "success": False,
                "error": str(e)
            }
  • The line where the info_tools module's register_tools function is called on the MCP server instance, registering the check_chain_exists tool along with other info tools.
    info_tools.register_tools(mcp)
  • Helper function get_client_credentials_client() that provides the KrogerAPI client instance used in the handler for accessing public endpoints like chain_exists.
    def get_client_credentials_client() -> KrogerAPI:
        """Get or create a client credentials authenticated client for public data"""
        global _client_credentials_client
        
        if _client_credentials_client is not None and _client_credentials_client.test_current_token():
            return _client_credentials_client
        
        _client_credentials_client = None
        
        try:
            load_and_validate_env(["KROGER_CLIENT_ID", "KROGER_CLIENT_SECRET"])
            _client_credentials_client = KrogerAPI()
            
            # Try to load existing token first
            token_file = ".kroger_token_client_product.compact.json"
            token_info = load_token(token_file)
            
            if token_info:
                # Test if the token is still valid
                _client_credentials_client.client.token_info = token_info
                if _client_credentials_client.test_current_token():
                    # Token is valid, use it
                    return _client_credentials_client
            
            # Token is invalid or not found, get a new one
            token_info = _client_credentials_client.authorization.get_token_with_client_credentials("product.compact")
            return _client_credentials_client
        except Exception as e:
            raise Exception(f"Failed to get client credentials: {str(e)}")
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 the tool checks existence and returns a dictionary, but lacks details on permissions, rate limits, error handling, or what the dictionary contains. This is a significant gap for a tool with zero annotation coverage.

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 well-structured and concise, with a clear purpose statement followed by Args and Returns sections. Every sentence earns its place, and it's front-loaded with the main functionality, making it easy to parse.

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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain the return dictionary's structure (e.g., keys like 'exists' or 'chain_id'), error cases, or behavioral traits like idempotency. For a tool with no structured data, more context is needed.

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 meaning beyond the input schema by explaining that 'chain_name' is the 'Name of the chain to check.' With 0% schema description coverage and only one parameter, this adequately compensates, though it could specify format or constraints for the chain name.

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: 'Check if a chain exists in the Kroger system.' It specifies the verb ('Check') and resource ('chain'), making it understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_chain_details' or 'list_chains', 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 sibling tools like 'get_chain_details' (for detailed info) or 'list_chains' (for listing all chains), nor does it specify prerequisites or exclusions, leaving usage unclear.

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