kroger-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kroger_mcp-0.1.0/.gitignore +37 -0
- kroger_mcp-0.1.0/LICENSE +21 -0
- kroger_mcp-0.1.0/PKG-INFO +336 -0
- kroger_mcp-0.1.0/README.md +281 -0
- kroger_mcp-0.1.0/pyproject.toml +63 -0
- kroger_mcp-0.1.0/src/kroger_mcp/__init__.py +9 -0
- kroger_mcp-0.1.0/src/kroger_mcp/cli.py +79 -0
- kroger_mcp-0.1.0/src/kroger_mcp/prompts.py +97 -0
- kroger_mcp-0.1.0/src/kroger_mcp/server.py +87 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/__init__.py +11 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/cart_tools.py +504 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/info_tools.py +274 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/location_tools.py +332 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/product_tools.py +484 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/profile_tools.py +184 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/shared.py +307 -0
- kroger_mcp-0.1.0/src/kroger_mcp/tools/utility_tools.py +33 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Virtual environment
|
|
2
|
+
venv/
|
|
3
|
+
.venv/
|
|
4
|
+
|
|
5
|
+
# Local Storage / Memory
|
|
6
|
+
*.json
|
|
7
|
+
|
|
8
|
+
# Token files
|
|
9
|
+
.kroger_token*
|
|
10
|
+
|
|
11
|
+
# Python cache files
|
|
12
|
+
__pycache__/
|
|
13
|
+
*.py[cod]
|
|
14
|
+
*$py.class
|
|
15
|
+
|
|
16
|
+
# Distribution / packaging
|
|
17
|
+
dist/
|
|
18
|
+
build/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
|
|
21
|
+
# Environment variables
|
|
22
|
+
.env
|
|
23
|
+
|
|
24
|
+
# IDE files
|
|
25
|
+
.idea/
|
|
26
|
+
.vscode/
|
|
27
|
+
|
|
28
|
+
# Test coverage
|
|
29
|
+
.coverage
|
|
30
|
+
coverage/
|
|
31
|
+
htmlcov/
|
|
32
|
+
|
|
33
|
+
# Logs
|
|
34
|
+
*.log
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
PUBLISHING.md
|
kroger_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Stephen Thoemmes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kroger-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: FastMCP server for Kroger API integration
|
|
5
|
+
Project-URL: Homepage, https://github.com/CupOfOwls/kroger-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/CupOfOwls/kroger-mcp
|
|
7
|
+
Project-URL: Issues, https://github.com/CupOfOwls/kroger-mcp/issues
|
|
8
|
+
Project-URL: Kroger_Documentation, https://developer.kroger.com/documentation/public/
|
|
9
|
+
Author-email: Stephen Thoemmes <thoemmes.stephen@gmail.com>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2025 Stephen Thoemmes
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: grocery,kroger,mcp,retail,shopping
|
|
33
|
+
Classifier: Development Status :: 4 - Beta
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
41
|
+
Classifier: Topic :: Office/Business
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Requires-Python: >=3.10
|
|
44
|
+
Requires-Dist: fastmcp>=2.0.0
|
|
45
|
+
Requires-Dist: kroger-api
|
|
46
|
+
Requires-Dist: pydantic>=2.0.0
|
|
47
|
+
Requires-Dist: python-dotenv
|
|
48
|
+
Requires-Dist: requests
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: black; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
53
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
# 🛒 Kroger MCP Server 🛍️ -- FastMCP for Kroger Shopping
|
|
57
|
+
|
|
58
|
+
A [FastMCP](https://github.com/jlowin/fastmcp) server that provides AI assistants like Claude with seamless access to Kroger's grocery shopping functionality through the Model Context Protocol ([MCP](https://docs.anthropic.com/en/docs/agents-and-tools/mcp)). This server enables AI assistants to find stores, search products, manage shopping carts, and access Kroger's comprehensive grocery data via the [kroger-api](https://github.com/CupOfOwls/kroger-api) python library.
|
|
59
|
+
|
|
60
|
+
## 📺 Demo
|
|
61
|
+
|
|
62
|
+
Using Claude with this MCP server to search for stores, find products, and add items to your cart:
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
## 🚀 Quick Start
|
|
67
|
+
|
|
68
|
+
### Prerequisites
|
|
69
|
+
You will need Kroger API credentials (free from [Kroger Developer Portal](https://developer.kroger.com/)).
|
|
70
|
+
Visit the [Kroger Developer Portal](https://developer.kroger.com/manage/apps/register) to:
|
|
71
|
+
1. Create a developer account
|
|
72
|
+
2. Register your application
|
|
73
|
+
3. Get your `CLIENT_ID`, `CLIENT_SECRET`, and set your `REDIRECT_URI`
|
|
74
|
+
|
|
75
|
+
The first time you run a tool requiring user authentication, you'll be prompted to authorize your app through your web browser. You're granting permission to **your own registered app**, not to any third party.
|
|
76
|
+
|
|
77
|
+
### Installation
|
|
78
|
+
|
|
79
|
+
#### Option 1: Using uvx with Claude Desktop (Recommended)
|
|
80
|
+
Once published to PyPI, you can use uvx to run the package directly without cloning the repository:
|
|
81
|
+
|
|
82
|
+
Edit Claude Desktop's configuration file:
|
|
83
|
+
|
|
84
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
85
|
+
|
|
86
|
+
**Linux**: `~/.config/Claude/claude_desktop_config.json`
|
|
87
|
+
|
|
88
|
+
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"kroger": {
|
|
94
|
+
"command": "uvx",
|
|
95
|
+
"args": [
|
|
96
|
+
"kroger-mcp"
|
|
97
|
+
],
|
|
98
|
+
"env": {
|
|
99
|
+
"KROGER_CLIENT_ID": "your_client_id",
|
|
100
|
+
"KROGER_CLIENT_SECRET": "your_client_secret",
|
|
101
|
+
"KROGER_REDIRECT_URI": "http://localhost:8000/callback",
|
|
102
|
+
"KROGER_USER_ZIP_CODE": "10001"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Benefits of this method:
|
|
110
|
+
- Automatically installs the package from PyPI if needed
|
|
111
|
+
- Creates an isolated environment for running the server
|
|
112
|
+
- Makes it easy to stay updated with the latest version
|
|
113
|
+
- Doesn't require maintaining a local repository clone
|
|
114
|
+
|
|
115
|
+
#### Option 2: Using uv with a Local Clone
|
|
116
|
+
First, clone locally:
|
|
117
|
+
```bash
|
|
118
|
+
git clone https://github.com/CupOfOwls/kroger-mcp
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Then, edit Claude Desktop's configuration file:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"mcpServers": {
|
|
126
|
+
"kroger": {
|
|
127
|
+
"command": "uv",
|
|
128
|
+
"args": [
|
|
129
|
+
"--directory",
|
|
130
|
+
"/path/to/cloned/kroger-mcp",
|
|
131
|
+
"run",
|
|
132
|
+
"kroger-mcp"
|
|
133
|
+
],
|
|
134
|
+
"env": {
|
|
135
|
+
"KROGER_CLIENT_ID": "your_client_id",
|
|
136
|
+
"KROGER_CLIENT_SECRET": "your_client_secret",
|
|
137
|
+
"KROGER_REDIRECT_URI": "http://localhost:8000/callback",
|
|
138
|
+
"KROGER_USER_ZIP_CODE": "10001"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Option 3: Installing From PyPI
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Install with uv (recommended)
|
|
149
|
+
uv pip install kroger-mcp
|
|
150
|
+
|
|
151
|
+
# Or install with pip
|
|
152
|
+
pip install kroger-mcp
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Option 4: Installing From Source
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Clone the repository
|
|
159
|
+
git clone https://github.com/CupOfOwls/kroger-mcp
|
|
160
|
+
cd kroger-mcp
|
|
161
|
+
|
|
162
|
+
# Install with uv (recommended)
|
|
163
|
+
uv sync
|
|
164
|
+
|
|
165
|
+
# Or install with pip
|
|
166
|
+
pip install -e .
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Configuration
|
|
170
|
+
|
|
171
|
+
Create a `.env` file in your project root or pass in env values via the JSON config:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Required: Your Kroger API credentials
|
|
175
|
+
KROGER_CLIENT_ID=your_client_id_here
|
|
176
|
+
KROGER_CLIENT_SECRET=your_client_secret_here
|
|
177
|
+
KROGER_REDIRECT_URI=http://localhost:8000/callback
|
|
178
|
+
|
|
179
|
+
# Optional: Default zip code for location searches
|
|
180
|
+
KROGER_USER_ZIP_CODE=90274
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Running the Server
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# With uv (recommended)
|
|
187
|
+
uv run kroger-mcp
|
|
188
|
+
|
|
189
|
+
# With uvx (directly from PyPI without installation)
|
|
190
|
+
uvx kroger-mcp
|
|
191
|
+
|
|
192
|
+
# Or with Python directly
|
|
193
|
+
python server.py
|
|
194
|
+
|
|
195
|
+
# With FastMCP CLI for development
|
|
196
|
+
fastmcp dev server.py --with-editable .
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
## 🛠️ Features
|
|
201
|
+
|
|
202
|
+
### 💬 Built-In MCP Prompts
|
|
203
|
+
- **Shopping Path**: Find optimal path through store for a grocery list
|
|
204
|
+
- **Pharmacy Check**: Check if pharmacy at preferred location is open
|
|
205
|
+
- **Store Selection**: Help user set their preferred Kroger store
|
|
206
|
+
- **Recipe Shopping**: Find recipes and add ingredients to cart
|
|
207
|
+
|
|
208
|
+
### 📚 Available Tools
|
|
209
|
+
|
|
210
|
+
#### Location Tools
|
|
211
|
+
|
|
212
|
+
| Tool | Description | Auth Required |
|
|
213
|
+
|------|-------------|---------------|
|
|
214
|
+
| `search_locations` | Find Kroger stores near a zip code | No |
|
|
215
|
+
| `get_location_details` | Get detailed information about a specific store | No |
|
|
216
|
+
| `set_preferred_location` | Set a preferred store for future operations | No |
|
|
217
|
+
| `get_preferred_location` | Get the currently set preferred store | No |
|
|
218
|
+
| `check_location_exists` | Verify if a location ID is valid | No |
|
|
219
|
+
|
|
220
|
+
#### Product Tools
|
|
221
|
+
|
|
222
|
+
| Tool | Description | Auth Required |
|
|
223
|
+
|------|-------------|---------------|
|
|
224
|
+
| `search_products` | Search for products by name, brand, or other criteria | No |
|
|
225
|
+
| `get_product_details` | Get detailed product information including pricing | No |
|
|
226
|
+
| `search_products_by_id` | Find products by their specific product ID | No |
|
|
227
|
+
| `get_product_images` | Get product images from specific perspective (front, back, etc.) | No |
|
|
228
|
+
|
|
229
|
+
#### Cart Tools
|
|
230
|
+
|
|
231
|
+
| Tool | Description | Auth Required |
|
|
232
|
+
|------|-------------|---------------|
|
|
233
|
+
| `add_items_to_cart` | Add a single item to cart | Yes |
|
|
234
|
+
| `bulk_add_to_cart` | Add multiple items to cart in one operation | Yes |
|
|
235
|
+
| `view_current_cart` | View items currently in your local cart tracking | No |
|
|
236
|
+
| `remove_from_cart` | Remove items from local cart tracking | No |
|
|
237
|
+
| `clear_current_cart` | Clear all items from local cart tracking | No |
|
|
238
|
+
| `mark_order_placed` | Move current cart to order history | No |
|
|
239
|
+
| `view_order_history` | View history of placed orders | No |
|
|
240
|
+
|
|
241
|
+
#### Information Tools
|
|
242
|
+
|
|
243
|
+
| Tool | Description | Auth Required |
|
|
244
|
+
|------|-------------|---------------|
|
|
245
|
+
| `list_chains` | Get all Kroger-owned chains | No |
|
|
246
|
+
| `get_chain_details` | Get details about a specific chain | No |
|
|
247
|
+
| `check_chain_exists` | Check if a chain exists | No |
|
|
248
|
+
| `list_departments` | Get all store departments | No |
|
|
249
|
+
| `get_department_details` | Get details about a specific department | No |
|
|
250
|
+
| `check_department_exists` | Check if a department exists | No |
|
|
251
|
+
|
|
252
|
+
#### Profile Tools
|
|
253
|
+
|
|
254
|
+
| Tool | Description | Auth Required |
|
|
255
|
+
|------|-------------|---------------|
|
|
256
|
+
| `get_user_profile` | Get authenticated user's profile information | Yes |
|
|
257
|
+
| `test_authentication` | Test if authentication token is valid | Yes |
|
|
258
|
+
| `get_authentication_info` | Get detailed authentication status | Yes |
|
|
259
|
+
| `force_reauthenticate` | Clear tokens and force re-authentication | No |
|
|
260
|
+
|
|
261
|
+
#### Utility Tools
|
|
262
|
+
|
|
263
|
+
| Tool | Description | Auth Required |
|
|
264
|
+
|------|-------------|---------------|
|
|
265
|
+
| `get_current_datetime` | Get current system date and time | No |
|
|
266
|
+
|
|
267
|
+
### 🧰 Local-Only Cart Tracking
|
|
268
|
+
|
|
269
|
+
Since the Kroger API doesn't provide cart viewing functionality, this server maintains local tracking:
|
|
270
|
+
|
|
271
|
+
#### Local Cart Storage
|
|
272
|
+
- **File**: `kroger_cart.json`
|
|
273
|
+
- **Contents**: Current cart items with timestamps
|
|
274
|
+
- **Automatic**: Created and updated automatically
|
|
275
|
+
|
|
276
|
+
#### Order History
|
|
277
|
+
- **File**: `kroger_order_history.json`
|
|
278
|
+
- **Contents**: Historical orders with placement timestamps
|
|
279
|
+
- **Usage**: Move completed carts to history with `mark_order_placed`
|
|
280
|
+
|
|
281
|
+
### 🚧 Kroger Public API Limitations
|
|
282
|
+
- **View Only**: The `remove_from_cart` and `clear_current_cart` tools ONLY affect local tracking, not the actual Kroger cart
|
|
283
|
+
- **Local Sync**: Use these tools only when the user has already removed items from their cart in the Kroger app/website
|
|
284
|
+
- **One-Way**: Items can be added to the Kroger cart but not removed through the Public API. The Partner API would allow these things, but that requires entering a contract with Kroger.
|
|
285
|
+
|
|
286
|
+
| API | Version | Rate Limit | Notes |
|
|
287
|
+
|-----|---------|------------|-------|
|
|
288
|
+
| **Authorization** | 1.0.13 | No specific limit | Token management |
|
|
289
|
+
| **Products** | 1.2.4 | 10,000 calls/day | Search and product details |
|
|
290
|
+
| **Locations** | 1.2.2 | 1,600 calls/day per endpoint | Store locations and details |
|
|
291
|
+
| **Cart** | 1.2.3 | 5,000 calls/day | Add/manage cart items |
|
|
292
|
+
| **Identity** | 1.2.3 | 5,000 calls/day | User profile information |
|
|
293
|
+
|
|
294
|
+
**Note:** Rate limits are enforced per endpoint, not per operation. You can distribute calls across operations using the same endpoint as needed.
|
|
295
|
+
|
|
296
|
+
## 🏫 Basic Workflow
|
|
297
|
+
|
|
298
|
+
1. **Set up a preferred location**:
|
|
299
|
+
```
|
|
300
|
+
User: "Find Kroger stores near 90274"
|
|
301
|
+
Assistant: [Uses search_locations tool]
|
|
302
|
+
User: "Set the first one as my preferred location"
|
|
303
|
+
Assistant: [Uses set_preferred_location tool]
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
2. **Search and add products**:
|
|
307
|
+
```
|
|
308
|
+
User: "Add milk to my cart"
|
|
309
|
+
Assistant: [Uses search_products, then add_items_to_cart]
|
|
310
|
+
|
|
311
|
+
User: "Add bread, eggs, and cheese to my cart"
|
|
312
|
+
Assistant: [Uses search_products for each, then bulk_add_to_cart]
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
3. **Manage cart and orders**:
|
|
316
|
+
```
|
|
317
|
+
User: "What's in my cart?"
|
|
318
|
+
Assistant: [Uses view_current_cart tool to see local memory]
|
|
319
|
+
|
|
320
|
+
User: "I placed the order on the Kroger website"
|
|
321
|
+
Assistant: [Uses mark_order_placed tool, moving current cart to the order history]
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## 🤝 Contributing
|
|
325
|
+
|
|
326
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
327
|
+
|
|
328
|
+
## 📄 License
|
|
329
|
+
|
|
330
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
331
|
+
|
|
332
|
+
## ⚠️ Disclaimer
|
|
333
|
+
|
|
334
|
+
This is an unofficial MCP server for the Kroger Public API. It is not affiliated with, endorsed by, or sponsored by Kroger.
|
|
335
|
+
|
|
336
|
+
For questions about the Kroger API, visit the [Kroger Developer Portal](https://developer.kroger.com/) or read the [kroger-api](https://github.com/CupOfOwls/kroger-api) package documentation.
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# 🛒 Kroger MCP Server 🛍️ -- FastMCP for Kroger Shopping
|
|
2
|
+
|
|
3
|
+
A [FastMCP](https://github.com/jlowin/fastmcp) server that provides AI assistants like Claude with seamless access to Kroger's grocery shopping functionality through the Model Context Protocol ([MCP](https://docs.anthropic.com/en/docs/agents-and-tools/mcp)). This server enables AI assistants to find stores, search products, manage shopping carts, and access Kroger's comprehensive grocery data via the [kroger-api](https://github.com/CupOfOwls/kroger-api) python library.
|
|
4
|
+
|
|
5
|
+
## 📺 Demo
|
|
6
|
+
|
|
7
|
+
Using Claude with this MCP server to search for stores, find products, and add items to your cart:
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## 🚀 Quick Start
|
|
12
|
+
|
|
13
|
+
### Prerequisites
|
|
14
|
+
You will need Kroger API credentials (free from [Kroger Developer Portal](https://developer.kroger.com/)).
|
|
15
|
+
Visit the [Kroger Developer Portal](https://developer.kroger.com/manage/apps/register) to:
|
|
16
|
+
1. Create a developer account
|
|
17
|
+
2. Register your application
|
|
18
|
+
3. Get your `CLIENT_ID`, `CLIENT_SECRET`, and set your `REDIRECT_URI`
|
|
19
|
+
|
|
20
|
+
The first time you run a tool requiring user authentication, you'll be prompted to authorize your app through your web browser. You're granting permission to **your own registered app**, not to any third party.
|
|
21
|
+
|
|
22
|
+
### Installation
|
|
23
|
+
|
|
24
|
+
#### Option 1: Using uvx with Claude Desktop (Recommended)
|
|
25
|
+
Once published to PyPI, you can use uvx to run the package directly without cloning the repository:
|
|
26
|
+
|
|
27
|
+
Edit Claude Desktop's configuration file:
|
|
28
|
+
|
|
29
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
30
|
+
|
|
31
|
+
**Linux**: `~/.config/Claude/claude_desktop_config.json`
|
|
32
|
+
|
|
33
|
+
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"kroger": {
|
|
39
|
+
"command": "uvx",
|
|
40
|
+
"args": [
|
|
41
|
+
"kroger-mcp"
|
|
42
|
+
],
|
|
43
|
+
"env": {
|
|
44
|
+
"KROGER_CLIENT_ID": "your_client_id",
|
|
45
|
+
"KROGER_CLIENT_SECRET": "your_client_secret",
|
|
46
|
+
"KROGER_REDIRECT_URI": "http://localhost:8000/callback",
|
|
47
|
+
"KROGER_USER_ZIP_CODE": "10001"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Benefits of this method:
|
|
55
|
+
- Automatically installs the package from PyPI if needed
|
|
56
|
+
- Creates an isolated environment for running the server
|
|
57
|
+
- Makes it easy to stay updated with the latest version
|
|
58
|
+
- Doesn't require maintaining a local repository clone
|
|
59
|
+
|
|
60
|
+
#### Option 2: Using uv with a Local Clone
|
|
61
|
+
First, clone locally:
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/CupOfOwls/kroger-mcp
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then, edit Claude Desktop's configuration file:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"kroger": {
|
|
72
|
+
"command": "uv",
|
|
73
|
+
"args": [
|
|
74
|
+
"--directory",
|
|
75
|
+
"/path/to/cloned/kroger-mcp",
|
|
76
|
+
"run",
|
|
77
|
+
"kroger-mcp"
|
|
78
|
+
],
|
|
79
|
+
"env": {
|
|
80
|
+
"KROGER_CLIENT_ID": "your_client_id",
|
|
81
|
+
"KROGER_CLIENT_SECRET": "your_client_secret",
|
|
82
|
+
"KROGER_REDIRECT_URI": "http://localhost:8000/callback",
|
|
83
|
+
"KROGER_USER_ZIP_CODE": "10001"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Option 3: Installing From PyPI
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Install with uv (recommended)
|
|
94
|
+
uv pip install kroger-mcp
|
|
95
|
+
|
|
96
|
+
# Or install with pip
|
|
97
|
+
pip install kroger-mcp
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Option 4: Installing From Source
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Clone the repository
|
|
104
|
+
git clone https://github.com/CupOfOwls/kroger-mcp
|
|
105
|
+
cd kroger-mcp
|
|
106
|
+
|
|
107
|
+
# Install with uv (recommended)
|
|
108
|
+
uv sync
|
|
109
|
+
|
|
110
|
+
# Or install with pip
|
|
111
|
+
pip install -e .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Configuration
|
|
115
|
+
|
|
116
|
+
Create a `.env` file in your project root or pass in env values via the JSON config:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Required: Your Kroger API credentials
|
|
120
|
+
KROGER_CLIENT_ID=your_client_id_here
|
|
121
|
+
KROGER_CLIENT_SECRET=your_client_secret_here
|
|
122
|
+
KROGER_REDIRECT_URI=http://localhost:8000/callback
|
|
123
|
+
|
|
124
|
+
# Optional: Default zip code for location searches
|
|
125
|
+
KROGER_USER_ZIP_CODE=90274
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Running the Server
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# With uv (recommended)
|
|
132
|
+
uv run kroger-mcp
|
|
133
|
+
|
|
134
|
+
# With uvx (directly from PyPI without installation)
|
|
135
|
+
uvx kroger-mcp
|
|
136
|
+
|
|
137
|
+
# Or with Python directly
|
|
138
|
+
python server.py
|
|
139
|
+
|
|
140
|
+
# With FastMCP CLI for development
|
|
141
|
+
fastmcp dev server.py --with-editable .
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## 🛠️ Features
|
|
146
|
+
|
|
147
|
+
### 💬 Built-In MCP Prompts
|
|
148
|
+
- **Shopping Path**: Find optimal path through store for a grocery list
|
|
149
|
+
- **Pharmacy Check**: Check if pharmacy at preferred location is open
|
|
150
|
+
- **Store Selection**: Help user set their preferred Kroger store
|
|
151
|
+
- **Recipe Shopping**: Find recipes and add ingredients to cart
|
|
152
|
+
|
|
153
|
+
### 📚 Available Tools
|
|
154
|
+
|
|
155
|
+
#### Location Tools
|
|
156
|
+
|
|
157
|
+
| Tool | Description | Auth Required |
|
|
158
|
+
|------|-------------|---------------|
|
|
159
|
+
| `search_locations` | Find Kroger stores near a zip code | No |
|
|
160
|
+
| `get_location_details` | Get detailed information about a specific store | No |
|
|
161
|
+
| `set_preferred_location` | Set a preferred store for future operations | No |
|
|
162
|
+
| `get_preferred_location` | Get the currently set preferred store | No |
|
|
163
|
+
| `check_location_exists` | Verify if a location ID is valid | No |
|
|
164
|
+
|
|
165
|
+
#### Product Tools
|
|
166
|
+
|
|
167
|
+
| Tool | Description | Auth Required |
|
|
168
|
+
|------|-------------|---------------|
|
|
169
|
+
| `search_products` | Search for products by name, brand, or other criteria | No |
|
|
170
|
+
| `get_product_details` | Get detailed product information including pricing | No |
|
|
171
|
+
| `search_products_by_id` | Find products by their specific product ID | No |
|
|
172
|
+
| `get_product_images` | Get product images from specific perspective (front, back, etc.) | No |
|
|
173
|
+
|
|
174
|
+
#### Cart Tools
|
|
175
|
+
|
|
176
|
+
| Tool | Description | Auth Required |
|
|
177
|
+
|------|-------------|---------------|
|
|
178
|
+
| `add_items_to_cart` | Add a single item to cart | Yes |
|
|
179
|
+
| `bulk_add_to_cart` | Add multiple items to cart in one operation | Yes |
|
|
180
|
+
| `view_current_cart` | View items currently in your local cart tracking | No |
|
|
181
|
+
| `remove_from_cart` | Remove items from local cart tracking | No |
|
|
182
|
+
| `clear_current_cart` | Clear all items from local cart tracking | No |
|
|
183
|
+
| `mark_order_placed` | Move current cart to order history | No |
|
|
184
|
+
| `view_order_history` | View history of placed orders | No |
|
|
185
|
+
|
|
186
|
+
#### Information Tools
|
|
187
|
+
|
|
188
|
+
| Tool | Description | Auth Required |
|
|
189
|
+
|------|-------------|---------------|
|
|
190
|
+
| `list_chains` | Get all Kroger-owned chains | No |
|
|
191
|
+
| `get_chain_details` | Get details about a specific chain | No |
|
|
192
|
+
| `check_chain_exists` | Check if a chain exists | No |
|
|
193
|
+
| `list_departments` | Get all store departments | No |
|
|
194
|
+
| `get_department_details` | Get details about a specific department | No |
|
|
195
|
+
| `check_department_exists` | Check if a department exists | No |
|
|
196
|
+
|
|
197
|
+
#### Profile Tools
|
|
198
|
+
|
|
199
|
+
| Tool | Description | Auth Required |
|
|
200
|
+
|------|-------------|---------------|
|
|
201
|
+
| `get_user_profile` | Get authenticated user's profile information | Yes |
|
|
202
|
+
| `test_authentication` | Test if authentication token is valid | Yes |
|
|
203
|
+
| `get_authentication_info` | Get detailed authentication status | Yes |
|
|
204
|
+
| `force_reauthenticate` | Clear tokens and force re-authentication | No |
|
|
205
|
+
|
|
206
|
+
#### Utility Tools
|
|
207
|
+
|
|
208
|
+
| Tool | Description | Auth Required |
|
|
209
|
+
|------|-------------|---------------|
|
|
210
|
+
| `get_current_datetime` | Get current system date and time | No |
|
|
211
|
+
|
|
212
|
+
### 🧰 Local-Only Cart Tracking
|
|
213
|
+
|
|
214
|
+
Since the Kroger API doesn't provide cart viewing functionality, this server maintains local tracking:
|
|
215
|
+
|
|
216
|
+
#### Local Cart Storage
|
|
217
|
+
- **File**: `kroger_cart.json`
|
|
218
|
+
- **Contents**: Current cart items with timestamps
|
|
219
|
+
- **Automatic**: Created and updated automatically
|
|
220
|
+
|
|
221
|
+
#### Order History
|
|
222
|
+
- **File**: `kroger_order_history.json`
|
|
223
|
+
- **Contents**: Historical orders with placement timestamps
|
|
224
|
+
- **Usage**: Move completed carts to history with `mark_order_placed`
|
|
225
|
+
|
|
226
|
+
### 🚧 Kroger Public API Limitations
|
|
227
|
+
- **View Only**: The `remove_from_cart` and `clear_current_cart` tools ONLY affect local tracking, not the actual Kroger cart
|
|
228
|
+
- **Local Sync**: Use these tools only when the user has already removed items from their cart in the Kroger app/website
|
|
229
|
+
- **One-Way**: Items can be added to the Kroger cart but not removed through the Public API. The Partner API would allow these things, but that requires entering a contract with Kroger.
|
|
230
|
+
|
|
231
|
+
| API | Version | Rate Limit | Notes |
|
|
232
|
+
|-----|---------|------------|-------|
|
|
233
|
+
| **Authorization** | 1.0.13 | No specific limit | Token management |
|
|
234
|
+
| **Products** | 1.2.4 | 10,000 calls/day | Search and product details |
|
|
235
|
+
| **Locations** | 1.2.2 | 1,600 calls/day per endpoint | Store locations and details |
|
|
236
|
+
| **Cart** | 1.2.3 | 5,000 calls/day | Add/manage cart items |
|
|
237
|
+
| **Identity** | 1.2.3 | 5,000 calls/day | User profile information |
|
|
238
|
+
|
|
239
|
+
**Note:** Rate limits are enforced per endpoint, not per operation. You can distribute calls across operations using the same endpoint as needed.
|
|
240
|
+
|
|
241
|
+
## 🏫 Basic Workflow
|
|
242
|
+
|
|
243
|
+
1. **Set up a preferred location**:
|
|
244
|
+
```
|
|
245
|
+
User: "Find Kroger stores near 90274"
|
|
246
|
+
Assistant: [Uses search_locations tool]
|
|
247
|
+
User: "Set the first one as my preferred location"
|
|
248
|
+
Assistant: [Uses set_preferred_location tool]
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
2. **Search and add products**:
|
|
252
|
+
```
|
|
253
|
+
User: "Add milk to my cart"
|
|
254
|
+
Assistant: [Uses search_products, then add_items_to_cart]
|
|
255
|
+
|
|
256
|
+
User: "Add bread, eggs, and cheese to my cart"
|
|
257
|
+
Assistant: [Uses search_products for each, then bulk_add_to_cart]
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
3. **Manage cart and orders**:
|
|
261
|
+
```
|
|
262
|
+
User: "What's in my cart?"
|
|
263
|
+
Assistant: [Uses view_current_cart tool to see local memory]
|
|
264
|
+
|
|
265
|
+
User: "I placed the order on the Kroger website"
|
|
266
|
+
Assistant: [Uses mark_order_placed tool, moving current cart to the order history]
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## 🤝 Contributing
|
|
270
|
+
|
|
271
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
272
|
+
|
|
273
|
+
## 📄 License
|
|
274
|
+
|
|
275
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
276
|
+
|
|
277
|
+
## ⚠️ Disclaimer
|
|
278
|
+
|
|
279
|
+
This is an unofficial MCP server for the Kroger Public API. It is not affiliated with, endorsed by, or sponsored by Kroger.
|
|
280
|
+
|
|
281
|
+
For questions about the Kroger API, visit the [Kroger Developer Portal](https://developer.kroger.com/) or read the [kroger-api](https://github.com/CupOfOwls/kroger-api) package documentation.
|