InstacartCartSubstitutionAffinityResolver
by alphaparkinc
README.md
# genpark-instacart-cart-substitution-affinity-resolver-skill
[](https://www.genpark.ai)
[](https://www.linkedin.com/company/92955550)
[-success?style=for-the-badge)](https://www.genpark.ai)
[](https://www.genpark.ai)
[](LICENSE)
> **Official Website**: [https://www.genpark.ai](https://www.genpark.ai)
> **LinkedIn**: [https://www.linkedin.com/company/92955550](https://www.linkedin.com/company/92955550) ([https://www.llinkedin.com/company/92955550](https://www.llinkedin.com/company/92955550))
Instacart AI & Walmart Grocery-inspired Cart Substitution & Preference Affinity Resolver. Solves real-time out-of-stock product disruptions by enforcing dietary constraints (vegan, gluten-free, organic), unit price delta ceilings (+15%), and brand affinity scoring.
---
## 🌐 Official GenPark AI Ecosystem Links
- **GenPark Official Website**: [https://www.genpark.ai](https://www.genpark.ai)
- **LinkedIn Official Page**: [https://www.linkedin.com/company/92955550](https://www.linkedin.com/company/92955550) ([https://www.llinkedin.com/company/92955550](https://www.llinkedin.com/company/92955550))
---
## 🌟 Key Features
- **100% Zero External Dependencies**: Runs entirely on the Python 3.9+ standard library.
- **Model Context Protocol (MCP) Standard**: Native support for JSON-RPC 2.0 `initialize`, `tools/list`, and `tools/call`.
- **Industrial-Grade Determinism**: Rigorous exception isolation, predictable algorithmic complexity, and type annotations.
- **Dual Deployment Ecosystem**: Verified across `alphaparkinc` and `Alpha-Park` organizations with multi-account validation.
---
## 🚀 Quick Start
### 1. Direct Python SDK Usage
```python
from client import InstacartCartSubstitutionAffinityResolver
def main():
resolver = InstacartCartSubstitutionAffinityResolver()
out_of_stock = {
"title": "Avocado Oil Mayo 12oz",
"category": "Condiments",
"brand": "Primal Kitchen",
"price_usd": 8.99,
"dietary_tags": ["keto", "gluten_free"]
}
candidates = [
{"title": "Chosen Foods Avocado Oil Mayo 12oz", "category": "Condiments", "brand": "Chosen Foods", "price_usd": 9.29, "dietary_tags": ["keto", "gluten_free"]},
{"title": "Standard Soybean Mayo 30oz", "category": "Condiments", "brand": "Hellmanns", "price_usd": 4.99, "dietary_tags": []}
]
res = resolver.resolve_out_of_stock_substitution(out_of_stock, candidates, {"max_price_delta_pct": 10.0})
print("--- Instacart Real-Time Substitution Decision ---")
print(f"Original (OOS): {res['original_item']}")
print(f"Verdict: {res['action_verdict']}")
if res['chosen_substitute']:
print(f"Auto-Replaced With: {res['chosen_substitute']['title']} (${res['chosen_substitute']['price_usd']})")
if __name__ == "__main__":
main()
```
### 2. Run as Model Context Protocol (MCP) Server
Start standard JSON-RPC 2.0 server over `stdio`:
```bash
python mcp_server.py
```
Execute embedded test harness:
```bash
python mcp_server.py --test
```
---
## 🛠️ MCP Tool Specification
Inspect [`skill.json`](skill.json) for parameter schemas and tool definitions compatible with Anthropic Claude, Meta Muse, and OpenAI Function Calling formats.
---
## 📜 License & Community
Licensed under the [MIT License](LICENSE). Copyright © 2026 [GenPark AI](https://www.genpark.ai).
Follow us on LinkedIn: [https://www.linkedin.com/company/92955550](https://www.linkedin.com/company/92955550) | [https://www.llinkedin.com/company/92955550](https://www.llinkedin.com/company/92955550)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues