get_chain_details
Retrieve comprehensive details about a specific Kroger chain by providing the chain name. Returns a dictionary with relevant chain information for analysis and decision-making.
Instructions
Get detailed information about a specific Kroger chain.
Args:
chain_name: Name of the chain to get details for
Returns:
Dictionary containing chain details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain_name | Yes |
Implementation Reference
- The @mcp.tool()-decorated async function that serves as the main handler for the get_chain_details tool, implementing the logic to fetch and return chain details from the Kroger API.@mcp.tool() async def get_chain_details( chain_name: str, ctx: Context = None ) -> Dict[str, Any]: """ Get detailed information about a specific Kroger chain. Args: chain_name: Name of the chain to get details for Returns: Dictionary containing chain details """ if ctx: await ctx.info(f"Getting details for chain: {chain_name}") client = get_client_credentials_client() try: chain_details = client.location.get_chain(chain_name) if not chain_details or "data" not in chain_details: return { "success": False, "message": f"Chain '{chain_name}' not found" } chain = chain_details["data"] return { "success": True, "name": chain.get("name"), "division_numbers": chain.get("divisionNumbers", []) } except Exception as e: if ctx: await ctx.error(f"Error getting chain details: {str(e)}") return { "success": False, "error": str(e) }
- src/kroger_mcp/server.py:75-75 (registration)Top-level call to register_tools from the info_tools module, which defines and registers the get_chain_details tool with the FastMCP server instance.info_tools.register_tools(mcp)
- src/kroger_mcp/tools/shared.py:25-53 (helper)Helper utility function that creates or retrieves a KrogerAPI client with client credentials authentication, used by get_chain_details to make API calls.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)}")