bob-cplex-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@bob-cplex-mcp solve this LP: maximize 3x + 5y subject to x <= 4, y <= 6, 3x + 2y <= 18, x, y >= 0"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
bob-cplex-mcp
Experimental Alpha — an MCP (Model Context Protocol) server exposing CPLEX-backed linear and mixed-integer programming tools, with fail-closed status reporting.
⚠️ Alpha status. This project does not yet claim full LP/MILP status reliability. It deliberately reports
unknownwhen the underlying solver interface cannot establish the true status. See Known Limitations before relying on any result.
What it is
An MCP server (
stdiotransport) registering two tools:solve_linear_program_toolandsolve_integer_program_tool.Models are built with PuLP (4.x compatible) and solved by an explicitly selected solver — CPLEX via PuLP's
CPLEX_CMD(file-based) interface by default.Every returned solution is independently verified against the model's constraints and objective by plain arithmetic. Verification proves the point is feasible — it is not proof of optimality.
Fail-closed status guards for the two misreport modes proven in the RC.1.1 spike (see below): results that cannot be established reliably are returned as
unknownwith no values, never as a confidently wrong status.
Related MCP server: SAGE
Why fail-closed
The upstream PuLP CPLEX_CMD interface infers status from files, which is
lossy. Two defects were proven experimentally (RC.1.1 spike, reproduced as
regression tests in tests/integration/):
LP-unbounded → reported
infeasible. CPLEX writes no solution file when it has no solution; PuLP then forcesInfeasible.MILP-unbounded → reported
optimalwith objective 0 and all-zero variables. The.solfile written aftermipoptdescribes the fixed-LP incumbent re-solve, not the MIP outcome.RC.3 audit additions: (a) a MIP that stopped on a time limit with an incumbent also surfaces as
optimal(same fixed-LP.solmechanism), and without an incumbent asinfeasible; (b) the RC.2 ±1e6-boxed probes could themselves misfire on models whose feasible region lies beyond the box (wrongly confirminginfeasibleor clearing an unbounded model asoptimal).
This server counters with: independent verification of every returned
point; the CPLEX log termination status for MIPs (MIP - Integer optimal
vs time-limit/unbounded strings, parsed by PuLP 4.3+ via orloge); an
unboundedness probe that treats inconclusive outcomes as fail-closed
unknown (and is skipped entirely for models bounded by construction); and
a zero-objective re-solve at the original bounds to disprove infeasible.
Where any check contradicts the verdict or is inconclusive, the status is
downgraded to unknown (or feasible for a verified but unproven
incumbent).
Requirements
Python 3.11+ (3.12 tested)
A CPLEX executable on
PATH(e.g., IBM ILOG CPLEX Studio Community Edition). Without it, solver requests fail with an explicit error — there is no silent fallback to another solver.No IBM CPLEX Python binding is required or used (the file-based
CPLEX_CMDinterface is used exclusively in this alpha).
Installation
python -m venv .venv
.venv/Scripts/activate # Windows
# source .venv/bin/activate # macOS / Linux
pip install .
# or for development:
pip install -e ".[dev]"MCP configuration
Example for clients that launch MCP servers via stdio (adjust paths):
{
"mcpServers": {
"bob-cplex-mcp": {
"command": "C:/path/to/bob-cplex-mcp/.venv/Scripts/bob-cplex-mcp.exe",
"args": []
}
}
}Usage examples
Via an MCP client (Bob / Cline)
Ask the agent to solve an LP; it will call solve_linear_program_tool:
Solve: maximize 3x + 5y subject to x <= 4, y <= 6, 3x + 2y <= 18, x,y >= 0Response fields: status (optimal / feasible / infeasible / unbounded
/ time_limit / unknown / error), objective_value, variables,
solver_info.solver_name, and — for verified solutions — a verification
note. See examples/ for runnable scripts.
Direct Python API
from bob_cplex_mcp.tools.linear_programming import solve_linear_program
result = solve_linear_program(
objective={"sense": "maximize", "coefficients": {"x": 3, "y": 5}},
variables={"x": {"type": "continuous", "lower": 0},
"y": {"type": "continuous", "lower": 0}},
constraints=[
{"expression": {"x": 1}, "operator": "<=", "rhs": 4},
{"expression": {"y": 1}, "operator": "<=", "rhs": 6},
{"expression": {"x": 3, "y": 2}, "operator": "<=", "rhs": 18},
],
solver="CPLEX",
)
print(result["status"], result["objective_value"]) # optimal 36.0Tests
# CPLEX-free unit tests (what CI runs):
pytest tests/unit -m "not cplex"
# CPLEX-gated integration tests (need cplex on PATH):
pytest tests/integrationKnown limitations
Status fidelity is fail-closed, not fully correct. Through the file-based
CPLEX_CMDinterface, genuinely unbounded models typically surface asunknown(notunbounded) because the interface never conveys unboundedness.unknownis the honest answer available from this adapter in this alpha.CPLEX Community Edition size limits (1000 variables / 1000 constraints) apply when using the free CPLEX.
Solver selection is explicit. If the requested solver is unavailable, the request fails; no fallback solver is selected.
The bounded re-solve probes use an artificial box of ±1e6; models whose true optimum lies beyond the box may be misjudged by a probe (in the conservative direction: downgrade to
unknown).SSE/HTTP transports are not built in this alpha (stdio only).
Diagnostics from CPLEX's interactive console (the honest "Integer unbounded" messages) are discarded by PuLP's interface and are not captured here.
Roadmap
CPLEX_PY adapter (requires installing the CPLEX Python binding) to restore true
unboundedstatuses — the recommended Path from the RC.1.1 architecture spike (Option D: multiple adapters behind one interface).Capture and expose CPLEX log/console diagnostics.
SSE transport; OR-Tools-based tools for non-CPLEX environments.
Provenance and license
Derived from mcp-optimizer
v0.4.1 (commit 65db2231711535033936975e7450032a3a494954), MIT licensed.
Local modifications: PuLP 4.2.0 compatibility, explicit solver selection,
fail-closed status guards with independent verification, LP/MILP-only tool
surface. See CHANGELOG.md and docs/PROVENANCE.md.
Contributing
This is an experimental alpha under active architecture work. Issues and
PRs are welcome; see docs/ for the architecture notes and known-defect
history before contributing solver-layer changes.
Available Tools
2 toolssolve_integer_program_toolSolve Integer Program ToolA
Solve an integer or mixed-integer programming problem using PuLP.
This tool solves optimization problems where some or all variables must take integer values, which is useful for discrete decision problems.
Use cases:
Facility location: Decide where to build warehouses or service centers
Project selection: Choose which projects to fund (binary decisions)
Crew scheduling: Assign integer numbers of staff to shifts
Network design: Design networks with discrete components
Cutting stock: Minimize waste when cutting materials
Capital budgeting: Select investments when partial investments aren't allowed
Inputs: objective (required), variables (required), constraints (required), solver, +1 more. Returns: object
solve_linear_program_toolSolve Linear Program ToolB
Solve a linear programming problem using PuLP.
This tool solves general linear programming problems where you want to optimize a linear objective function subject to linear constraints.
Use cases:
Resource allocation: Distribute limited resources optimally
Diet planning: Create nutritionally balanced meal plans within budget
Manufacturing mix: Determine optimal product mix to maximize profit
Investment planning: Allocate capital across different investment options
Supply chain optimization: Minimize transportation and storage costs
Energy optimization: Optimize power generation and distribution
Inputs: objective (required), variables (required), constraints (required), solver, +1 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools target distinct problem classes—continuous LP versus integer/MIP—and descriptions clarify the boundary. However, because MILP subsumes LP and the integer tool handles mixed-integer cases, an agent may occasionally misselect when deciding whether discreteness is required.
Both names follow the same predictable snake_case verb_noun_tool pattern: solve_linear_program_tool and solve_integer_program_tool. The redundant _tool suffix is consistent and does not impair readability.
Two tools is thin for a solver server; the surface offers only solving entry points and no auxiliary operations. The count is borderline but the tools themselves are well-scoped.
Core LP and MILP solving are covered, but notable gaps remain: no explicit solution-status retrieval, sensitivity/dual analysis, model validation, solver option configuration, or save/load of formulations. Agents can work around this if solve responses include full results, but the lifecycle is incomplete.
Maintenance
Related MCP Connectors
Build custom optimization engines in conversation: optimize from your assistant via MCP, or by API.
Solve production, blending, transport and scheduling problems with LP and MIP.
Optimize crew and workforce schedules, resource allocation, and routing with linear and mixed-inte…
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables solving Constraint Satisfaction Problems (CSP) like N-Queens, graph coloring, and Sudoku, as well as Linear Programming optimization problems through both MCP tools and HTTP API endpoints.2MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude Desktop and MCP-compatible agents to formulate, solve, and certify mathematical optimization problems using production-grade open-source solvers, providing mathematically grounded decisions.MIT
- AlicenseAqualityBmaintenanceEnables AI agents to describe combinatorial optimization problems as JSON and obtain validated, ranked, re-verified solutions through MCP tools.4180 PyPIMIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP-capable agents to solve scheduling and integer optimization problems using Google OR-Tools, return proven-optimal or valid solutions, independently verify proposed solutions, and explain infeasible rule sets.MIT