USolver is a Model Context Protocol (MCP) tool for solving optimization and constraint satisfaction problems using various solvers:
- Z3 Solver: Solve constraint satisfaction and optimization problems with boolean, integer, real, and string variables (e.g., logic puzzles, symbolic constraints)
- HiGHs Solver: Handle linear programming (LP) and mixed-integer programming (MIP) problems with support for dense/sparse matrices, various algorithms (simplex, interior point), and detailed solver options
- CVXPY Solver: Solve convex optimization problems with matrix operations and parameterized problems
- OR-Tools Solver: Address combinatorial optimization problems like scheduling, routing, and resource allocation using boolean, integer, and interval variables
USolver supports both detailed and simplified interfaces across various domains including finance, chemical engineering, transportation, and scheduling.
Used to format responses and queries, enabling structured presentation of mathematical problems, optimization constraints, and solution outputs in a readable format.
USolver
A Model Context Protocol server that exposes tools for solving combinatorial, convex, integer programming, and non-linear optimization problems. Exposes interfaces to the following solvers:
highs
- Linear and mixed-integer programming solverortools
- Combinatorial optimization solvercvxpy
- Convex optimization solverz3
- SMT solver over booleans, integers, reals, and strings
To install run the install.py
script. This will install the MPC server for Claude Desktop and/or Cursor.
Then open Claude or Cursor and you should see the MCP tool usolver
available in the tool list.
Examples
To run the individual solver examples you can invoke the individual example modules. Each module contains a docstring which can be used to prompt the language model to solve the problem.
- Chemical Engineering - Pipeline design optimization using Z3 SMT solver for fluid transport systems with flow continuity, pressure drop, and economic constraints
- Chained Solvers - Multi-stage restaurant optimization combining OR-Tools for table layout and CVXPY for staff scheduling
- Job Shop Scheduling - Complex scheduling problem using OR-Tools to minimize makespan while respecting operation precedence and machine capacity
- Logistics - Transportation network optimization using HiGHS to minimize shipping costs in multi-stage supply chains
- Nurse Scheduling - Hospital staff scheduling using OR-Tools to assign nurses to shifts with fairness and availability constraints
- Portfolio Theory - Modern portfolio optimization using CVXPY to maximize returns while constraining risk across asset classes
- Production Planning - Manufacturing optimization using HiGHS to maximize profit subject to machine, labor, and material constraints
- Resource Allocation - Project portfolio selection using HiGHS mixed-integer programming to maximize value within budget and resource limits
- Network Flow - Shortest path optimization using HiGHS linear programming to find minimum-cost routes through directed graphs with flow conservation constraints
- Coin Problem - Classic logic puzzle using Z3 to find which 6 US coins total $1.15 but cannot make change for various denominations
- Cryptarithmetic - Solve cryptarithmetic puzzles like SEND + MORE = MONEY using Z3 constraint programming
- Knapsack Problem - Classic 0/1 knapsack optimization using OR-Tools to maximize value within weight constraints
- Multilinear Optimization - Linear programming with mixed constraints using Z3 to minimize objective functions subject to linear inequalities
- N-Queens - Place N queens on an N×N chessboard using OR-Tools constraint programming with no attacking positions
- Sparse Solver - Large-scale optimization demonstrating sparse matrix formats for memory-efficient resource allocation across facilities and time periods
Logic Puzzle
This can be fed into usolver and it will generate a constraint system:
Loading... is the collection of the six unknown coin values, Loading... through Loading..., each of which must be a positive whole number representing cents.
Loading...Loading... is the collection of every possible way you could choose two or more of your six coins.
Loading...Exclude the 50 cent coin from being used in the vending machine.
Loading...Constraint 0: The sum of the values of all six coins is 115 cents.
Loading...Constraint 1: Cannot make change for a dollar.
Loading...Constraint 2: Cannot make change for half a dollar.
Loading...Constraint 3: Cannot make change for a quarter.
Loading...Constraint 4: Cannot make change for a dime.
Loading...Constraint 5: Cannot make change for a nickel
Loading...Constraint 6: Cannot buy the candy bar for 95 cents if half dollar is excluded.
Loading...If you feed this to solver it will synthesize the above constraint system, solve it with Z3, and return the solution.
Modern Portfolio Theory
A finance example:
This is compiled by the langauge model down into a convex optimization problem that can be cvxopt.
Loading...Where:
- Loading... = Bonds allocation
- Loading... = Stocks allocation
- Loading... = Real Estate allocation
- Loading... = Commodities allocation
The answer is then:
Z3
A chemical engineering example:
Linear Programming
A multilinear optimization example:
This is compiled by the language model down into a constraint satisfaction problem that can be solved with Z3.
Loading...Where:
- Loading... = First decision variable (continuous, non-negative)
- Loading... = Second decision variable (continuous, bounded)
The optimal solution is:
CVXPY
A simple convex optimization problem minimizing the 2-norm of a linear system:
OR-Tools
A classic worker shift scheduling problem:
Chained Examples
A chained example that uses both OR-Tools to optimize for table layout and CVXPY to optimize for staff scheduling.
Docker Usage
Can also run the MCP server directly from the GitHub Container Registry.
Then add the following to your client:
License
Released under the Apache License 2.0. See the LICENSE file for details.
Tools
A best-effort universal logic and numerical solver interface using MCP that implements the 'LLM sandwich' model to process queries, call dedicated solvers (ortools, cvxpy, z3), and verbalize results.
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol (MCP) server that provides mathematical calculations and operations using NumPy, enabling users to perform numerical computations like matrix operations, statistical analysis, and polynomial fitting directly through Claude.Last updated -1Python
- AsecurityFlicenseAqualityA lightweight MCP server that provides a unified interface to various LLM providers including OpenAI, Anthropic, Google Gemini, Groq, DeepSeek, and Ollama.Last updated -6491Python
- AsecurityAlicenseAqualityA Model Context Protocol server that provides basic calculator functionality for LLMs, enabling them to perform mathematical operations like addition, subtraction, multiplication, division, modulo, and square root.Last updated -612512TypeScriptMIT License
- -security-license-qualityA tool server that processes mathematical expressions via Multi-Chain Protocol (MCP), allowing LLMs to solve math problems through tool integration.Last updated -PythonMIT License