Kroger MCP server

Integrates with Kroger's grocery API to search products, find store locations, retrieve pricing and availability information, and manage shopping carts through OAuth2 authentication.
Back to servers
Setup instructions
Provider
Eric Lott
Release date
May 29, 2025
Stats
1 star

The Kroger MCP Server allows language models like Claude to interact with Kroger's grocery services, enabling product searches, store lookups, and cart management through the Model Context Protocol (MCP).

Installation and Configuration

API Credentials Setup

  1. Register an application on the Kroger Developer Portal to obtain a Client ID and Secret
  2. Configure credentials in config.py:
# config.py
KROGER_CLIENT_ID = "YOUR_ACTUAL_CLIENT_ID"
KROGER_CLIENT_SECRET = "YOUR_ACTUAL_CLIENT_SECRET"
KROGER_REDIRECT_URI = "http://localhost:8080/callback"

User Authorization for Cart Operations

To enable cart management functionality:

  1. Run the authorization script:

    python auth.py
    
  2. Follow the displayed instructions:

    • Open the provided authorization URL in your browser
    • Log in with your Kroger account and grant access
    • Copy the authorization code from the redirect URL
    • Paste the code back into the script when prompted
  3. Store the refresh token in config.py:

    KROGER_USER_REFRESH_TOKEN = "YOUR_SAVED_REFRESH_TOKEN"
    

Starting the Server

  1. Install required dependencies:

    pip install requests mcp
    
  2. Launch the server:

    python server.py
    

The server uses STDIO for communication with MCP clients and doesn't open network ports. To stop the server, press Ctrl+C in the terminal.

Connecting to an MCP Client

Claude Desktop Integration

  1. Open Claude Desktop and go to Settings
  2. Navigate to the Integrations section
  3. Click "Add MCP Server"
  4. Enter the command to run the server:
    python /path/to/your/project/server.py
    

Programmatic Integration

You can interact with the server programmatically using an MCP client library:

from modelcontext import Client, StdioClientTransport

async def main():
    client = Client(name="example-kroger-client", version="1.0", capabilities={})
    transport = StdioClientTransport(command=["python", "server.py"])
    
    await client.connect(transport)
    
    # Find stores near a ZIP code
    store_results = await client.call_tool(
        "find_stores", 
        {"zip_code": "45202", "limit": 1}
    )
    
    # Search for products
    if store_results and len(store_results) > 0:
        location_id = store_results[0].get("locationId")
        product_results = await client.call_tool(
            "search_products",
            {"query": "milk", "location_id": location_id, "limit": 2}
        )
        
    await client.disconnect()

Available Tools

The server provides the following capabilities:

Find Stores

find_stores(zip_code: str, radius_miles: int = 10, limit: int = 5)

Locates Kroger stores near a specified ZIP code.

Search Products

search_products(query: str, location_id: str, limit: int = 10)

Searches for products by keyword at a specific store location.

Get Product Details

get_product(product_id: str, location_id: str)

Retrieves detailed information about a specific product.

Add to Cart

add_to_cart(product_id: str, quantity: int, location_id: str)

Adds a product to the user's Kroger cart (requires user authorization).

Troubleshooting

Missing User Authorization

If you try to use cart functions without authorization, you'll receive an error message instructing you to complete the OAuth2 flow.

Token Issues

If tokens expire, the server will attempt to refresh them automatically. If the refresh token is invalid, you'll need to re-authorize.

API Rate Limits

Kroger's API has rate limits. If exceeded, the server will return an error with HTTP 429 status code. Wait before trying again.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "kroger" '{"command":"python","args":["server.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "kroger": {
            "command": "python",
            "args": [
                "server.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "kroger": {
            "command": "python",
            "args": [
                "server.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later