texas-grocery-mcp 0.1.0__py3-none-any.whl

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.
Files changed (40) hide show
  1. texas_grocery_mcp/__init__.py +3 -0
  2. texas_grocery_mcp/auth/__init__.py +5 -0
  3. texas_grocery_mcp/auth/browser_refresh.py +1629 -0
  4. texas_grocery_mcp/auth/credentials.py +337 -0
  5. texas_grocery_mcp/auth/session.py +767 -0
  6. texas_grocery_mcp/clients/__init__.py +5 -0
  7. texas_grocery_mcp/clients/graphql.py +2400 -0
  8. texas_grocery_mcp/models/__init__.py +54 -0
  9. texas_grocery_mcp/models/cart.py +60 -0
  10. texas_grocery_mcp/models/coupon.py +44 -0
  11. texas_grocery_mcp/models/errors.py +43 -0
  12. texas_grocery_mcp/models/health.py +41 -0
  13. texas_grocery_mcp/models/product.py +274 -0
  14. texas_grocery_mcp/models/store.py +77 -0
  15. texas_grocery_mcp/observability/__init__.py +6 -0
  16. texas_grocery_mcp/observability/health.py +141 -0
  17. texas_grocery_mcp/observability/logging.py +73 -0
  18. texas_grocery_mcp/reliability/__init__.py +23 -0
  19. texas_grocery_mcp/reliability/cache.py +116 -0
  20. texas_grocery_mcp/reliability/circuit_breaker.py +138 -0
  21. texas_grocery_mcp/reliability/retry.py +96 -0
  22. texas_grocery_mcp/reliability/throttle.py +113 -0
  23. texas_grocery_mcp/server.py +211 -0
  24. texas_grocery_mcp/services/__init__.py +5 -0
  25. texas_grocery_mcp/services/geocoding.py +227 -0
  26. texas_grocery_mcp/state.py +166 -0
  27. texas_grocery_mcp/tools/__init__.py +5 -0
  28. texas_grocery_mcp/tools/cart.py +821 -0
  29. texas_grocery_mcp/tools/coupon.py +381 -0
  30. texas_grocery_mcp/tools/product.py +437 -0
  31. texas_grocery_mcp/tools/session.py +486 -0
  32. texas_grocery_mcp/tools/store.py +353 -0
  33. texas_grocery_mcp/utils/__init__.py +5 -0
  34. texas_grocery_mcp/utils/config.py +146 -0
  35. texas_grocery_mcp/utils/secure_file.py +123 -0
  36. texas_grocery_mcp-0.1.0.dist-info/METADATA +296 -0
  37. texas_grocery_mcp-0.1.0.dist-info/RECORD +40 -0
  38. texas_grocery_mcp-0.1.0.dist-info/WHEEL +4 -0
  39. texas_grocery_mcp-0.1.0.dist-info/entry_points.txt +2 -0
  40. texas_grocery_mcp-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,296 @@
1
+ Metadata-Version: 2.4
2
+ Name: texas-grocery-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for HEB grocery store integration
5
+ Author: Michael Walker
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: ai,grocery,heb,llm,mcp
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: beautifulsoup4>=4.12
16
+ Requires-Dist: cryptography>=42.0
17
+ Requires-Dist: fastmcp>=2.0
18
+ Requires-Dist: httpx>=0.27
19
+ Requires-Dist: keyring>=25.0
20
+ Requires-Dist: prometheus-client>=0.19
21
+ Requires-Dist: pydantic-settings>=2.0
22
+ Requires-Dist: pydantic>=2.0
23
+ Requires-Dist: redis>=5.0
24
+ Requires-Dist: structlog>=24.0
25
+ Provides-Extra: browser
26
+ Requires-Dist: playwright>=1.40.0; extra == 'browser'
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy>=1.8; extra == 'dev'
29
+ Requires-Dist: playwright>=1.40.0; extra == 'dev'
30
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
31
+ Requires-Dist: pytest-cov>=4.1; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: respx>=0.21; extra == 'dev'
34
+ Requires-Dist: ruff>=0.1; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Texas Grocery MCP
38
+
39
+ An MCP (Model Context Protocol) server that enables AI agents to interact with HEB grocery stores for product search, product details, cart management, and digital coupons.
40
+
41
+ This project is **not affiliated with H-E-B**. It uses unofficial web APIs and browser automation against HEB.com; use responsibly and ensure your usage complies with applicable terms and laws.
42
+
43
+ ## Features
44
+
45
+ - **Store Search**: Find HEB stores by address or zip code
46
+ - **Product Search**: Search products with pricing and availability
47
+ - **Cart Management**: Add/remove items with human-in-the-loop confirmation
48
+ - **Product Details**: Ingredients, nutrition facts, allergens, warnings, and dietary attributes
49
+ - **Coupons**: List/search/clip digital coupons (requires authentication)
50
+ - **Session Management**: Refresh sessions automatically (fast with embedded Playwright)
51
+
52
+ ## Installation
53
+
54
+ ### Basic Installation
55
+
56
+ ```bash
57
+ pip install texas-grocery-mcp
58
+ ```
59
+
60
+ This provides all core functionality. Session refresh requires orchestrating Playwright MCP (~4 minutes).
61
+
62
+ ### Full Installation (Recommended)
63
+
64
+ ```bash
65
+ pip install texas-grocery-mcp[browser]
66
+ playwright install chromium
67
+ ```
68
+
69
+ This enables **fast auto-refresh** (~15 seconds) using an embedded browser. Adds ~150MB for Chromium.
70
+
71
+ ### Prerequisites
72
+
73
+ For cart operations and session management, you'll also need **Microsoft Playwright MCP**:
74
+
75
+ ```bash
76
+ npm install -g @anthropic-ai/mcp-playwright
77
+ ```
78
+
79
+ ## Configuration
80
+
81
+ ### Claude Desktop
82
+
83
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "playwright": {
89
+ "command": "npx",
90
+ "args": ["@anthropic-ai/mcp-playwright"]
91
+ },
92
+ "heb": {
93
+ "command": "uvx",
94
+ "args": ["texas-grocery-mcp"],
95
+ "env": {
96
+ "HEB_DEFAULT_STORE": "590"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ ### Environment Variables
104
+
105
+ | Variable | Description | Default |
106
+ |----------|-------------|---------|
107
+ | `HEB_DEFAULT_STORE` | Default store ID | None |
108
+ | `REDIS_URL` | Redis cache URL | None (in-memory) |
109
+ | `LOG_LEVEL` | Logging level | INFO |
110
+
111
+ ## Usage
112
+
113
+ ### Finding a Store
114
+
115
+ ```
116
+ User: Find HEB stores near Austin, TX
117
+
118
+ Agent uses: store_search(address="Austin, TX", radius_miles=10)
119
+ ```
120
+
121
+ ### Searching Products
122
+
123
+ ```
124
+ User: Search for organic milk
125
+
126
+ Agent uses: store_change(store_id="590")
127
+ Agent uses: product_search(query="organic milk")
128
+ ```
129
+
130
+ ### Getting Product Details
131
+
132
+ For detailed information about a specific product (ingredients, nutrition, allergens, warnings):
133
+
134
+ ```
135
+ User: What are the ingredients in H-E-B olive oil?
136
+
137
+ Agent uses: product_search(query="heb olive oil")
138
+ # Returns products with product_id
139
+
140
+ Agent uses: product_get(product_id="127074")
141
+ # Returns detailed info: ingredients, nutrition facts, warnings, dietary attributes
142
+ ```
143
+
144
+ The `product_get` tool returns comprehensive information including:
145
+ - **Ingredients**: Full ingredient statement
146
+ - **Nutrition Facts**: Complete FDA panel with serving size, calories, and all nutrients
147
+ - **Safety Warnings**: Allergen info and safety precautions
148
+ - **Dietary Attributes**: Gluten-free, organic, vegan, kosher, etc.
149
+ - **Preparation/Storage**: Instructions for use and storage
150
+ - **Store Location**: Aisle or section where product is located
151
+
152
+ ### Adding to Cart
153
+
154
+ Cart operations require authentication via Playwright MCP:
155
+
156
+ ```
157
+ User: Add 2 gallons of milk to my cart
158
+
159
+ Agent uses: cart_add(product_id="123456", quantity=2)
160
+ # Returns preview with confirm=true instruction
161
+
162
+ Agent uses: cart_add(product_id="123456", quantity=2, confirm=true)
163
+ # Executes the action
164
+ ```
165
+
166
+ ## Session Management
167
+
168
+ HEB uses bot detection (reese84 token) that expires every ~11 minutes. This MCP handles session refresh automatically.
169
+
170
+ ### Fast Auto-Refresh (Recommended)
171
+
172
+ If you installed with `[browser]` support:
173
+
174
+ ```
175
+ Agent uses: session_refresh()
176
+ # Completes in ~10-15 seconds
177
+ ```
178
+
179
+ This runs an embedded browser to refresh your session automatically.
180
+
181
+ ### Manual Refresh (Fallback)
182
+
183
+ Without browser support, use the Playwright MCP orchestration:
184
+
185
+ ```
186
+ Agent uses: session_refresh()
187
+ # Returns Playwright commands to execute (~4 minutes)
188
+ ```
189
+
190
+ ### Initial Login
191
+
192
+ For first-time authentication or when session fully expires:
193
+
194
+ 1. `browser_navigate('https://www.heb.com/my-account/login')`
195
+ 2. Complete login in the browser
196
+ 3. Save storage state:
197
+ ```javascript
198
+ await page.context().storageState({ path: '~/.texas-grocery-mcp/auth.json' })
199
+ ```
200
+ 4. Retry cart operations
201
+
202
+ Or use `session_refresh(headless=False)` to login in a visible browser window.
203
+
204
+ ## Available Tools
205
+
206
+ ### Store Tools
207
+ - `store_search` - Find stores by address
208
+ - `store_change` - Set preferred store (syncs with HEB.com when authenticated)
209
+ - `store_get_default` - Get current default store
210
+
211
+ ### Product Tools
212
+ - `product_search` - Search products by name with pricing and availability
213
+ - `product_search_batch` - Search multiple products at once (up to 20 queries)
214
+ - `product_get` - Get comprehensive product details (ingredients, nutrition, warnings, dietary attributes)
215
+
216
+ ### Cart Tools
217
+ - `cart_check_auth` - Check authentication status
218
+ - `cart_get` - View cart contents
219
+ - `cart_add` - Add item (requires confirmation)
220
+ - `cart_add_with_retry` - Add item with automatic retry on failure
221
+ - `cart_remove` - Remove item (requires confirmation)
222
+
223
+ ### Coupon Tools
224
+ - `coupon_list` - List available digital coupons
225
+ - `coupon_search` - Search coupons by keyword
226
+ - `coupon_categories` - Get coupon category list
227
+ - `coupon_clip` - Clip a coupon to your account (requires confirmation)
228
+ - `coupon_clipped` - List your clipped coupons
229
+
230
+ ### Session Tools
231
+ - `session_status` - Check session health and token expiration
232
+ - `session_refresh` - Refresh/login (fast with `[browser]`, otherwise returns Playwright MCP commands)
233
+ - `session_save_instructions` - Get manual login + session-save instructions
234
+ - `session_save_credentials` - Save credentials for auto-login (secure)
235
+ - `session_clear_credentials` - Remove saved credentials
236
+ - `session_clear` - Clear saved session (logout)
237
+
238
+ ### Health Tools
239
+ - `health_live` - Liveness probe
240
+ - `health_ready` - Readiness probe with component status
241
+
242
+ ## Documentation
243
+
244
+ - [Troubleshooting Guide](docs/TROUBLESHOOTING.md) - Solutions for common issues
245
+
246
+ ## Development
247
+
248
+ ```bash
249
+ # Clone repository
250
+ git clone https://github.com/yourusername/texas-grocery-mcp
251
+ cd texas-grocery-mcp
252
+
253
+ # Install with dev dependencies (includes Playwright)
254
+ pip install -e ".[dev]"
255
+ playwright install chromium
256
+
257
+ # Run tests
258
+ pytest tests/ -v
259
+
260
+ # Run linting
261
+ ruff check src/
262
+
263
+ # Run type checking
264
+ mypy src/
265
+ ```
266
+
267
+ ### Docker Development
268
+
269
+ ```bash
270
+ # Build and run with Redis
271
+ docker-compose up --build
272
+
273
+ # Run tests in container
274
+ docker-compose run texas-grocery-mcp pytest
275
+ ```
276
+
277
+ ## Architecture
278
+
279
+ ```
280
+ ┌─────────────────────────────────────────────────────────────┐
281
+ │ User's MCP Environment │
282
+ │ │
283
+ │ ┌─────────────────────┐ ┌─────────────────────────────┐ │
284
+ │ │ Playwright MCP │ │ Texas Grocery MCP │ │
285
+ │ │ (Browser Auth) │───▶│ (Grocery Logic) │ │
286
+ │ └─────────────────────┘ └─────────────────────────────┘ │
287
+ │ │ │
288
+ └────────────────────────────────────────┼─────────────────────┘
289
+
290
+
291
+ HEB GraphQL API
292
+ ```
293
+
294
+ ## License
295
+
296
+ MIT
@@ -0,0 +1,40 @@
1
+ texas_grocery_mcp/__init__.py,sha256=X5acO89_cdDdyPbAHrrcHuC3APD29uRbYf90YCrVsV0,94
2
+ texas_grocery_mcp/server.py,sha256=ysY8c8GDNYVCFd96v29meaBPoL5LyUFae-d6YdKk_Us,8064
3
+ texas_grocery_mcp/state.py,sha256=I4QianF2myRA7rWEjl3ReSW1uc1uJZbgvztLTfLjSF8,5675
4
+ texas_grocery_mcp/auth/__init__.py,sha256=K4dysnkkzEBfnCfRWgdg-FAoLlGZT08eXukxPdyhtGw,200
5
+ texas_grocery_mcp/auth/browser_refresh.py,sha256=T3Ncy26PcvJOeE_xR7Br8esa9JCconO1OXO8IMeHHXg,60911
6
+ texas_grocery_mcp/auth/credentials.py,sha256=fNMAAf4QvBp4YcDTbM1h9FknKrGlYhvjEX4x3PN0z2E,11264
7
+ texas_grocery_mcp/auth/session.py,sha256=6_FZJoUNXM7W0P-eHSzyoYkrv1AEkSpukKE4mTHx_q8,24883
8
+ texas_grocery_mcp/clients/__init__.py,sha256=DnNJVNq2LwFJShdaAjpJcHF-ivFaiJmuLhinhuOPHs0,137
9
+ texas_grocery_mcp/clients/graphql.py,sha256=2gMpXYP1LRzup6-dJEw6KunM92ZB4-7bdl1Q9Ru2zyI,87360
10
+ texas_grocery_mcp/models/__init__.py,sha256=XY0aiazApqvvFITBoMwNzhXq-SCknRReo88ztPA_KWQ,1280
11
+ texas_grocery_mcp/models/cart.py,sha256=E0jjHS5uttLA0aQeyR49LExPmSkp7v2KsVPCtcx2Z_w,2005
12
+ texas_grocery_mcp/models/coupon.py,sha256=uhgbfwVZ81TAJ-3rFw9jEgoQty3a7aws6vaqMGiK5qU,1851
13
+ texas_grocery_mcp/models/errors.py,sha256=AmCMyfQoIUoGN1Si8yqZo6BXHL1Afak5-QxNjmwgjAU,1525
14
+ texas_grocery_mcp/models/health.py,sha256=vohg3IKQMWH5Yww_40xyisn9eli--9XenEYvA-LBJ6U,1309
15
+ texas_grocery_mcp/models/product.py,sha256=Qwvpwy2699oiZZk-xGM_AAAHxjA8ahcCLzpxVLK0J6w,10526
16
+ texas_grocery_mcp/models/store.py,sha256=8EExIEFjhNt0B0oBA-67rg3KEeVCb4jpiIjXCtChyfs,2936
17
+ texas_grocery_mcp/observability/__init__.py,sha256=UnCGf_KCwgEJ6zZoI3BZ__yie5gjD6B7ANdZF0fnvic,296
18
+ texas_grocery_mcp/observability/health.py,sha256=_XkaKY0pM5QLN7zORfFbYxku8lCmUuEY5eNCLh8D_io,4329
19
+ texas_grocery_mcp/observability/logging.py,sha256=n6gEBTs15o4eaFkr1jUsAUGEi27LQQqTFjFziUaX1nI,2164
20
+ texas_grocery_mcp/reliability/__init__.py,sha256=cWOb-zyIAdeuoofOR5Q7bSCJZOF4lh9VPTWPB3esySQ,624
21
+ texas_grocery_mcp/reliability/cache.py,sha256=hefUCyioP2ezHDCTrIH_x7oEtsbIccuzfUTatHMAhkY,3469
22
+ texas_grocery_mcp/reliability/circuit_breaker.py,sha256=Lx5j990kDuGbLsxh4pnLwAlfLKXRx2Imutjhfylcabo,4686
23
+ texas_grocery_mcp/reliability/retry.py,sha256=K5XdXPl4DhFQkuXY1Wj754LxVYkvPxlzA0pEsNqipSI,2851
24
+ texas_grocery_mcp/reliability/throttle.py,sha256=N1pDtjO3u_0epwXUgCqec9zypTRDs7ofCmg1G8jgmig,3155
25
+ texas_grocery_mcp/services/__init__.py,sha256=PZxNtdO_xyThxhNapA_fSO6ikNFBFY1UOrh3vAEj1dk,173
26
+ texas_grocery_mcp/services/geocoding.py,sha256=I9fPTP3KLYHLth4GyYZSWzDPza_XkuCL6eU6hmf4WqM,6936
27
+ texas_grocery_mcp/tools/__init__.py,sha256=5za_ExgYTkwNaSMy3U1YwtPhlkmf9_LKb7Hjq4EDWCs,164
28
+ texas_grocery_mcp/tools/cart.py,sha256=jEeimL6DPuTT6UdNb8ecssGe1QyPRnhO89BoPRzr99I,27344
29
+ texas_grocery_mcp/tools/coupon.py,sha256=VfujygAov4bDqM0kmvIv0K4bO0NqMtepLT4DwhW_NXA,10368
30
+ texas_grocery_mcp/tools/product.py,sha256=bHmvWURYoDYau--zj-voQwOPo9Em2ZynczcuNiDVT98,14155
31
+ texas_grocery_mcp/tools/session.py,sha256=DtoCq2K37PsxOCcW1pNqy0gz8On5yq0NHLUtlaBUhL4,17266
32
+ texas_grocery_mcp/tools/store.py,sha256=UAyoIJbzfNmtnFnwM3jJs1WMlYuzrmG3tnywif-ochY,11716
33
+ texas_grocery_mcp/utils/__init__.py,sha256=sSMOf8isFMso1DsFdsppLIXEsPv0CtAKI1heHG_p1ec,152
34
+ texas_grocery_mcp/utils/config.py,sha256=CtB8HqnEFRkHbT7NR3iMIRJtZJBxYEEB2IWYuaL_0e4,4052
35
+ texas_grocery_mcp/utils/secure_file.py,sha256=Y8vlkN9rL4VQPg1-39lZz937HpR4FDbUpQWXULhbwAg,3200
36
+ texas_grocery_mcp-0.1.0.dist-info/METADATA,sha256=XMdLMP_yXhIxTSXDZ6rR2UK0w4QaEtAzC3opU7wprDw,9219
37
+ texas_grocery_mcp-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
+ texas_grocery_mcp-0.1.0.dist-info/entry_points.txt,sha256=i0MQYbryCcZryfCvkBkNx_3bdi4UnddscJA2wgCYOic,68
39
+ texas_grocery_mcp-0.1.0.dist-info/licenses/LICENSE,sha256=KRosPCO4879Stw30rAviYap_rxEBG2RIpqMogAcnxFY,1071
40
+ texas_grocery_mcp-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ texas-grocery-mcp = texas_grocery_mcp.server:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael Walker
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.