OptimEngine - Operations Scheduling & Routing Solver

Created By
MicheleCampi4 months ago
Solves Flexible Job Shop Scheduling (FJSP) and Capacitated Vehicle Routing with Time Windows (CVRPTW) using Google OR-Tools. MCP-native for AI agents. 5 tools: optimize_schedule, validate_schedule, optimize_routing, health_check, root.
Overview

⚡ OptimEngine — Operations Intelligence Solver

The first MCP Server for production scheduling, vehicle routing, and bin packing optimization.

An AI-native solver that assigns tasks to machines, deliveries to vehicles, and items to bins optimally using constraint programming. Built for the agentic economy: AI agents discover it, call it, and pay for it — autonomously.

MCP Compatible OR-Tools Python 3.12+ Tests License: MIT


What It Does

OptimEngine solves three families of NP-hard optimization problems that LLMs cannot compute:

1. Scheduling — Flexible Job Shop (FJSP)

Assign tasks to machines optimally with precedence, time windows, machine eligibility, setup times, priorities, and multiple objectives.

2. Routing — CVRPTW

Assign delivery locations to vehicles optimally with capacity constraints, time windows, service times, GPS coordinates, and multiple objectives.

3. Bin Packing

Assign items to bins/containers optimally with weight/volume constraints, item quantities, group constraints, and multiple objectives.

The core insight: LLMs understand optimization requests in natural language but cannot compute optimal solutions. These are NP-hard problems that require specialized solvers. OptimEngine is that solver, exposed as MCP tools that any AI agent can call.


MCP Tools

ToolProblemInputOutput
optimize_scheduleFlexible Job Shop SchedulingJobs, tasks, machines, constraintsOptimal schedule + Gantt + metrics
validate_scheduleSchedule verificationSchedule + constraintsViolations + suggestions
optimize_routingVehicle Routing + Time WindowsDepot, locations, vehicles, capacityOptimal routes + stop times + metrics
optimize_packingBin PackingItems (weight/volume), bins (capacity)Optimal assignments + bin summaries + metrics

Scheduling Capabilities

FeatureDetails
Flexible Job ShopTasks can run on multiple eligible machines
PrecedenceTasks within a job execute in defined order
Time WindowsEarliest start, latest end per job
Machine AvailabilityMachines have operational windows
Setup TimesPer-task setup time before processing
PrioritiesJob priority (1-10) for weighted objectives
4 ObjectivesMinimize makespan, total/max tardiness, balance load
Schedule ValidationVerify existing schedules, get violation reports
Gantt DataReady-to-render visualization in every response

Routing Capabilities

FeatureDetails
Capacity ConstraintsPer-vehicle maximum load
Time WindowsEarliest/latest arrival per location
Service TimesTime spent at each delivery point
GPS CoordinatesHaversine distance from lat/lon
Custom Distance MatrixOverride with your own distances/times
Drop VisitsSkip infeasible locations with penalty
Per-Vehicle LimitsMax travel time/distance per vehicle
4 ObjectivesMinimize distance, time, vehicles, or balance routes

Packing Capabilities

FeatureDetails
Weight + VolumeDual-dimension capacity constraints
Item QuantitiesPack N copies of an item type
Bin TypesMultiple bin sizes with different costs
Group ConstraintsKeep related items in the same bin
Max Items per BinLimit number of items per container
Partial PackingAllow unpacked items for over-constrained problems
4 ObjectivesMinimize bins, maximize value/items, balance load

Quick Start

1. Install & Run

git clone https://github.com/MicheleCampi/optim-engine.git
cd optim-engine
pip install -r requirements.txt
uvicorn api.server:app --host 0.0.0.0 --port 8000

Server starts at http://localhost:8000. Docs at /docs. MCP endpoint at /mcp.

2. Connect via MCP (Claude Desktop, Cursor, etc.)

{
  "mcpServers": {
    "optim-engine": {
      "command": "mcp-proxy",
      "args": ["https://optim-engine-production.up.railway.app/mcp"]
    }
  }
}

Example — Scheduling

curl -X POST https://optim-engine-production.up.railway.app/optimize_schedule \
  -H "Content-Type: application/json" \
  -d '{
    "jobs": [
      {"job_id": "J1", "tasks": [
        {"task_id": "cut", "duration": 3, "eligible_machines": ["M1", "M2"]},
        {"task_id": "weld", "duration": 2, "eligible_machines": ["M2"]}
      ], "due_date": 10},
      {"job_id": "J2", "tasks": [
        {"task_id": "cut", "duration": 4, "eligible_machines": ["M1"]},
        {"task_id": "weld", "duration": 3, "eligible_machines": ["M2"]}
      ], "due_date": 12}
    ],
    "machines": [{"machine_id": "M1"}, {"machine_id": "M2"}],
    "objective": "minimize_makespan"
  }'

Example — Routing

curl -X POST https://optim-engine-production.up.railway.app/optimize_routing \
  -H "Content-Type: application/json" \
  -d '{
    "depot_id": "warehouse",
    "locations": [
      {"location_id": "warehouse", "demand": 0},
      {"location_id": "customer_A", "demand": 20, "time_window_end": 3000, "service_time": 10},
      {"location_id": "customer_B", "demand": 15, "time_window_end": 4000, "service_time": 10},
      {"location_id": "customer_C", "demand": 25, "time_window_end": 5000, "service_time": 15}
    ],
    "vehicles": [
      {"vehicle_id": "truck_1", "capacity": 40},
      {"vehicle_id": "truck_2", "capacity": 40}
    ],
    "distance_matrix": [
      {"from_id": "warehouse", "to_id": "customer_A", "distance": 500, "travel_time": 500},
      {"from_id": "warehouse", "to_id": "customer_B", "distance": 800, "travel_time": 800},
      {"from_id": "warehouse", "to_id": "customer_C", "distance": 600, "travel_time": 600},
      {"from_id": "customer_A", "to_id": "warehouse", "distance": 500, "travel_time": 500},
      {"from_id": "customer_A", "to_id": "customer_B", "distance": 400, "travel_time": 400},
      {"from_id": "customer_A", "to_id": "customer_C", "distance": 700, "travel_time": 700},
      {"from_id": "customer_B", "to_id": "warehouse", "distance": 800, "travel_time": 800},
      {"from_id": "customer_B", "to_id": "customer_A", "distance": 400, "travel_time": 400},
      {"from_id": "customer_B", "to_id": "customer_C", "distance": 300, "travel_time": 300},
      {"from_id": "customer_C", "to_id": "warehouse", "distance": 600, "travel_time": 600},
      {"from_id": "customer_C", "to_id": "customer_A", "distance": 700, "travel_time": 700},
      {"from_id": "customer_C", "to_id": "customer_B", "distance": 300, "travel_time": 300}
    ],
    "objective": "minimize_total_distance"
  }'

Example — Bin Packing

curl -X POST https://optim-engine-production.up.railway.app/optimize_packing \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"item_id": "laptop", "weight": 3, "volume": 8, "value": 1200, "quantity": 10},
      {"item_id": "monitor", "weight": 8, "volume": 25, "value": 500, "quantity": 5},
      {"item_id": "keyboard", "weight": 1, "volume": 3, "value": 80, "quantity": 20}
    ],
    "bins": [
      {"bin_id": "small_box", "weight_capacity": 20, "volume_capacity": 50, "cost": 5, "quantity": 5},
      {"bin_id": "large_box", "weight_capacity": 50, "volume_capacity": 120, "cost": 12, "quantity": 3}
    ],
    "objective": "minimize_bins"
  }'

Use Cases

  • Manufacturing: Production scheduling for contract manufacturing (cosmetics, pharma, food)
  • Logistics: Last-mile delivery routing with time windows and capacity
  • Warehouse: Bin packing for palletization, container loading, order fulfillment
  • Cloud/IT: Resource allocation (VMs to servers, jobs to clusters)
  • Food Delivery: Multi-driver route optimization
  • Supply Chain: End-to-end scheduling + routing + packing

Architecture

AI Agent (Claude, GPT, Gemini, etc.)
    ▼ MCP Protocol
┌────────────────────────────────────────┐
│  FastAPI + fastapi-mcp                  │  ← API layer
├────────────┬────────────┬──────────────┤
│ Scheduling │  Routing   │  Bin Packing │
│ CP-SAT     │  Routing   │  CP-SAT      │
│            │  Library   │              │  ← OR-Tools solvers
├────────────┴────────────┴──────────────┤
│  Pydantic Models                        │  ← Schema contract
└────────────────────────────────────────┘

Stack: Python 3.12 · FastAPI · OR-Tools (CP-SAT + Routing) · fastapi-mcp · Pydantic v2


Tests

pip install pytest
python -m pytest tests/ -v

97 tests covering: flexible job shop, time windows, due dates, machine availability, setup times, CVRPTW routing, capacity, GPS distances, bin packing, weight/volume constraints, group constraints, partial packing, and realistic manufacturing/delivery/warehouse scenarios.


Landing Page

🌐 optim-engine.vercel.app

Marketplace Listings


License

MIT


Built with Google OR-Tools — the optimization toolkit used by Google for fleet routing, scheduling, and resource allocation at scale.

Project Info
Created At
4 months ago
Updated At
4 months ago
Author Name
MicheleCampi
Star
-
Language
-
License
-
Category

Recommend Servers

View All
//beforeyouship — LLM Cost Modeling From Your Editor
@Indiegoing

Query realistic LLM cost models without leaving your editor. beforeyouship models the **true monthly cost** of an LLM app architecture — retries, prompt caching, batch discounts, infra overhead, and 3×/10× growth — across GPT-5.x, Claude, Gemini, DeepSeek, and more. Not a token calculator: a planning tool for the design phase, before you commit to a stack. **No API key needed to try it** — demo mode covers the six free-tier models. A Pro key from [beforeyouship.dev](https://beforeyouship.dev) unlocks the full 18-model catalog. ## What you can ask - "How much will a RAG chatbot cost at 10,000 requests/day?" - "Compare Claude Haiku vs Gemini Flash pricing for my workload" - "What's the cheapest model for a multi-step agent at scale?" - "Show me current per-token prices for Anthropic models" ## Tools ### `estimate_cost` Full cost model for an architecture at a given usage level. Returns Naive / Realistic / Worst Case monthly cost per model, 3×/10× growth scenarios, and an opinionated recommendation with reasoning. ### `get_model_prices` Current per-1M-token pricing — input, output, cached input, batch — with context windows and staleness metadata. ### `list_archetypes` Seven preset architecture patterns (simple chatbot, chatbot with history, RAG pipeline, multi-model router, coding assistant, document processor, multi-step agent) used as starting points for estimates. ## Setup **Claude Code:** ​```bash claude mcp add --transport http beforeyouship https://beforeyouship.dev/api/mcp ​``` **Cursor / other clients** — add a remote server: ​```json { "mcpServers": { "beforeyouship": { "type": "streamable-http", "url": "https://beforeyouship.dev/api/mcp" } } } ​``` Add an `Authorization: Bearer bys_...` header with a Pro key for the full catalog. ## Try it > Estimate the monthly cost of a RAG pipeline at 10,000 requests/day

10 hours ago
Puter Mcp

2 days ago
Linkpulse

13 hours ago