Skip to main content
Glama
CupOfOwls

Kroger MCP Server

start_authentication

Initiates OAuth authentication with Kroger by generating a URL for browser authorization, then requires users to copy and paste the callback URL to complete the process.

Instructions

    Start the OAuth authentication flow with Kroger.
    
    This tool returns a URL that the user needs to open in their browser
    to authenticate with Kroger. After authorization, the user will be
    redirected to a callback URL that they need to copy and paste back.
    
    Returns:
        Dictionary with authorization URL and instructions
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for start_authentication tool. Generates PKCE parameters, builds OAuth authorization URL for Kroger API, and provides user instructions for the browser-based flow.
    @mcp.tool()
    async def start_authentication(ctx: Context = None) -> Dict[str, Any]:
        """
        Start the OAuth authentication flow with Kroger.
        
        This tool returns a URL that the user needs to open in their browser
        to authenticate with Kroger. After authorization, the user will be
        redirected to a callback URL that they need to copy and paste back.
        
        Returns:
            Dictionary with authorization URL and instructions
        """
        global _pkce_params, _auth_state
        
        # Generate PKCE parameters
        _pkce_params = generate_pkce_parameters()
        
        # Generate a state parameter for CSRF protection
        _auth_state = _pkce_params.get('state', _pkce_params.get('code_verifier')[:16])
        
        # Get client_id and redirect_uri from environment
        client_id = os.environ.get("KROGER_CLIENT_ID")
        redirect_uri = os.environ.get("KROGER_REDIRECT_URI", "http://localhost:8000/callback")
        
        if not client_id:
            if ctx:
                await ctx.error("Missing KROGER_CLIENT_ID environment variable")
            return {
                "error": True,
                "message": "Missing KROGER_CLIENT_ID environment variable. Please set up your Kroger API credentials."
            }
        
        # Initialize the Kroger API client
        kroger = KrogerAPI()
        
        # Scopes needed for Kroger API (cart.basic:write is needed for cart operations)
        scopes = "product.compact cart.basic:write"
        
        # Get the authorization URL with PKCE
        auth_url = kroger.authorization.get_authorization_url(
            scope=scopes,
            state=_auth_state,
            code_challenge=_pkce_params["code_challenge"],
            code_challenge_method=_pkce_params["code_challenge_method"]
        )
        
        if ctx:
            await ctx.info(f"Generated auth URL with PKCE: {auth_url}")
        
        return {
            "auth_url": auth_url,
            "instructions": (
                "1. Click this link to authorize: [🔗 Authorize Kroger Access]({auth_url})\n"
                "   - Please present the authorization URL as a clickable markdown link\n"
                "2. Log in to your Kroger account and authorize the application\n"
                "3. After authorization, you'll be redirected to a callback URL\n"
                "4. Copy the FULL redirect URL from your browser's address bar\n"
                "5. Use the complete_authentication tool with that URL to complete the process"
            ).format(auth_url=auth_url)
        }
  • Registers the authentication tools by delegating to auth.register_auth_tools(mcp). This is called from server.py.
    def register_tools(mcp):
        """Register authentication tools with the FastMCP server"""
        register_auth_tools(mcp)
  • Site where auth_tools.register_tools is invoked during server initialization, registering the start_authentication tool.
    auth_tools.register_tools(mcp)
  • Function that defines and registers both start_authentication and complete_authentication tools using @mcp.tool() decorators.
    def register_auth_tools(mcp):
        """Register authentication-specific tools with the FastMCP server"""
Behavior3/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 effectively describes the tool's behavior: it returns a URL for OAuth flow and requires user interaction (opening in browser, copying callback URL). However, it lacks details on potential errors, timeouts, or prerequisites, leaving some behavioral aspects unclear.

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 front-loaded with the core purpose in the first sentence, followed by essential details about the return value and user instructions. Each sentence adds value without redundancy, and the structure is logical and efficient, making it easy to parse quickly.

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

Completeness4/5

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

Given the tool's complexity (authentication flow) and lack of annotations or output schema, the description does a good job explaining the process and return value. However, it could be more complete by mentioning error handling or linking to 'complete_authentication' for the next step, slightly reducing the score.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately does not discuss parameters, focusing on the tool's purpose and output. A baseline of 4 is applied since it compensates well for the lack of parameters by explaining the tool's function clearly.

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

Purpose5/5

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

The description clearly states the specific action ('Start the OAuth authentication flow') and the target resource ('with Kroger'), distinguishing it from sibling tools like 'complete_authentication' or 'test_authentication'. It precisely defines what the tool initiates without being vague or tautological.

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

Usage Guidelines4/5

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

The description provides clear context on when to use this tool: to begin authentication with Kroger, returning a URL for browser-based authorization. However, it does not explicitly state when not to use it (e.g., if already authenticated) or name alternatives like 'force_reauthenticate' for different scenarios, limiting it to a 4.

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