Skip to main content
Glama
mertkaraca04

gurobi-ie

by mertkaraca04

gurobi-ie-mcp

An MCP server that connects Claude to the Gurobi optimisation solver for industrial-engineering problems.

Ask Claude in plain language ("make an 8-week production plan from this Excel file", "what if week 6 loses 200 hours?", "which warehouses should we open?") and it builds the optimisation model, solves it with Gurobi, and explains the result: the plan, the cost, which constraints are binding, and what an extra hour of capacity is worth.

Course project for Gen AI for Engineers, Yaşar University, October 2026. Team: Mert Karaca, Rafet Kaan Alhan, Berke Sezer


How it works

flowchart LR
    U[You: plain-language request] --> C[Claude Desktop / Claude Code]
    C -- MCP tool call --> S[server.py<br/>gurobi-ie MCP server]
    S -- builds LP / MIP --> G[Gurobi solver<br/>gurobipy]
    G -- solution, duals, IIS --> S
    S -- JSON result --> C
    S <-- reads / writes --> X[(Excel files)]

Claude chooses a tool and fills in its parameters, server.py turns them into a Gurobi model, and Gurobi solves it. The result comes back to Claude, which interprets it or asks for the next run. Every tool call is visible in the chat and needs your approval.

Related MCP server: HiGHS MCP Server

Tools

Tool

Problem

What you get back

production_plan

Multi-product, multi-period aggregate planning: production, inventory, overtime, optional backorders and setup costs (LP or MIP)

Plan per period, cost breakdown, capacity utilisation, shadow price of capacity; if infeasible, the conflicting constraints (IIS). Optional Excel output with a capacity chart.

facility_location

Capacitated facility location (MIP)

Facilities to open, shipments, fixed vs transport cost, utilisation

schedule_jobs

Parallel identical machines, minimise makespan or weighted tardiness (MIP)

Start/end per job and machine, tardiness, text Gantt chart

solve_custom_model

Any LP/MIP written out explicitly: product mix, blending, assignment, staffing…

Variable values, objective, shadow prices, slacks, reduced costs (LP)

read_excel_table

Load input data from an .xlsx file

Headers and rows

The docstrings in server.py are the "manual" Claude reads to decide which tool to use, so every parameter name includes its unit (_hours, _units, _per_unit).

Setup

Requirements: Python 3.10+ and Claude Desktop (or Claude Code). No Gurobi licence setup is needed: pip install gurobipy ships a free size-limited licence (2000 variables / 2000 constraints), which is enough for course-sized models.

Windows

  1. Download this repository (Code → Download ZIP) and extract it.

  2. Double-click install.bat. It installs gurobipy, mcp and openpyxl, solves a test model, and prints the full path to server.py.

  3. In Claude Desktop open Settings → Developer → Edit Config and add this block inside the top-level { } of claude_desktop_config.json (keep everything that is already there, and write every \ as \\):

"mcpServers": {
  "gurobi-ie": {
    "command": "py",
    "args": ["C:\\path\\to\\gurobi-ie-mcp\\server.py"]
  }
},
  1. Fully quit Claude Desktop (also from the system tray) and reopen it. gurobi-ie should appear in the tools menu with 5 tools.

macOS / Linux

pip install -r requirements.txt
# Claude Code:
claude mcp add gurobi-ie -- python3 /path/to/gurobi-ie-mcp/server.py

For Claude Desktop on macOS the config file is ~/Library/Application Support/Claude/claude_desktop_config.json; use "command": "python3".

Try it

demo_demand.xlsx holds 8 weeks of demand for a heating-products plant (boilers, heat pumps, water heaters) plus capacities and costs.

Use gurobi-ie. Read demo_demand.xlsx (both sheets) and build an 8-week production plan with whole units. Write it to plan_output.xlsx. Which weeks are at full capacity?

Result (also in examples/plan_output.xlsx):

Week

Boiler

Heat pump

Water heater

Utilisation

W1

90

30

150

48 %

W2

130

45

210

70 %

W3

150

60

180

77 %

W4

170

70

190

86 %

W5

160

80

290

99 %

W6

140

90

305

100 %

W7

180

100

190

100 %

W8

200

110

115

100 %

Total cost 29,797,000 TL with no overtime: Gurobi builds water heaters early in weeks 5–6 so that weeks 7–8 fit in regular hours.

Follow-up "what-if" questions used in the live demo are in DEMO_SCRIPT.md: a maintenance week, the value of extra capacity (shadow prices), an infeasible plan explained by its IIS, scheduling and facility location.

Checked by hand

  • Week 1 hours: 90 × 2 + 30 × 3.5 + 150 × 1 = 435 h ≤ 900 h. ✔

  • Facility location demo: opening Manisa and Aydın gives capacity 450 ≥ demand 370; fixed cost 6,500 + transport 920 = 7,420, the same as the solver's answer. ✔

  • Week 1 under a supplier delay: it needs 435 h but only 300 + 120 = 420 h exist, which is why the solver reports infeasibility in weeks 1–2. ✔

Design choices

  • Why our own server and not Gurobi's official one? Gurobi offers an official MCP server (Gurobi Intelligence) that runs in Docker, needs an Intelligence Hub account, and generates gurobipy code with AI agents. For a course demo we wanted no account or Docker, the free licence, and a small set of fixed, tested tools whose behaviour is predictable during live modifications.

  • Structured tools plus one general tool: the three IE tools cover common problems with validated models. solve_custom_model lets Claude formulate anything else on the spot.

  • Explain, not just solve: shadow prices, slacks and the IIS of infeasible models are returned so Claude can say why the answer is what it is.

Safety and limits (handout section 7 checklist)

Check

Answer

Official or community?

Our own server, using Gurobi's official gurobipy library

Licence

MIT (this repo); Gurobi's free pip licence is size-limited and for evaluation and academic use

Software / OS

Python 3.10+, any OS; tested on Windows with Claude Desktop

Mock or real?

Real: every result comes from the Gurobi solver. There is no mock fallback; errors are returned as errors.

Risky tools?

No code execution, no deletion. It only reads the Excel files you name and writes the output file you name.

Size limit

Free licence: 2000 variables / 2000 constraints. schedule_jobs proves optimality in about a second for up to ~8 jobs; larger cases return the best schedule found within the time limit (default 20 s) and say it is not proven optimal.

An optimal answer is only as good as the model and data. Units, costs, capacities and assumptions remain the engineer's responsibility.

Tests

cd tests && python test_client.py

This starts the server as a real MCP client would and calls every tool.

Use of AI

The server code, tests, documentation and demo data were written with Claude (Anthropic). We reviewed the models, ran the tests, and checked the key numerical results by hand (see "Checked by hand").

Licence

MIT. See LICENSE.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables solving linear programming (LP) and mixed-integer linear programming (MILP) optimization problems through natural language, with built-in simplex and branch-and-cut solvers plus infeasibility diagnostics. Includes optional OR-Tools fallback for larger problems and supports parsing optimization problems from natural language descriptions.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides linear programming (LP), mixed-integer programming (MIP), and quadratic programming (QP) optimization capabilities using the HiGHS solver, enabling AI assistants to solve complex optimization problems like production planning, logistics, and portfolio optimization.
    32 npm
    17
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI applications to solve optimization problems including linear programming, mixed-integer programming, and quadratic programming using the Gurobi solver installed on the local device.
    1
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides nine specialized production-ready solvers for advanced resource allocation, network flow, and multi-objective optimization with native Monte Carlo integration. It enables users to perform constraint-based decision-making and performance analysis directly through Claude Code.
    MIT