Article illustration 1

When an AI assistant can't solve a logic puzzle involving coin combinations or optimize a billion-dollar investment portfolio, it's typically due to limited access to specialized computational tools. Enter USolver, an open-source Model Context Protocol (MCP) server that bridges this gap by exposing four powerful optimization engines to AI coding assistants like Claude and Cursor.

The Solver Arsenal

USolver integrates:

  1. HiGHS for linear/mixed-integer programming (logistics, production planning)
  2. OR-Tools for combinatorial optimization (scheduling, routing)
  3. CVXPY for convex optimization (portfolio theory, resource allocation)
  4. Z3 for SMT solving (logic puzzles, cryptographic constraints)

This toolkit transforms natural language problem descriptions into executable optimization models. For example, the classic "vending machine coin puzzle"—where six coins sum to $1.15 but can't make change for any standard denomination—is compiled into Z3 constraints:

# Z3 constraint formulation for coin puzzle
Constraint 0: Σcoins = 115¢
Constraint 1: ∀S⊆coins, |S|≥2 → ΣS ≠ 100¢
Constraint 2: ∀S⊆coins, |S|≥2 → ΣS ≠ 50¢
... # (dime, nickel constraints)
Constraint 6: ∀S⊆coins, Σv(x)≠95¢ (v(x)=0 if x=50 else x)

USolver deduces the solution: one half-dollar, one quarter, and four dimes.

Real-World Applications

Beyond puzzles, USolver handles industrial-scale problems:

  • Portfolio Optimization: Maximizing returns while constraining risk:

    maximize: 0.08x₁ + 0.12x₂ + 0.10x₃ + 0.15x₄
    subject to: 
      x₁≤0.4, x₂≤0.6, x₃≤0.3, x₄≤0.2
      0.02x₁ + 0.15x₂ + 0.08x₃ + 0.20x₄ ≤ 0.10
      Σx_i=1, x_i≥0
    

    Result: 30% bonds, 20% stocks, 30% real estate, 20% commodities → 10.8% return.

  • Chemical Engineering: Optimizing pipeline diameter (D) and flow velocity (v) given:

    ΔP = f(L/D)(ρv²/2) ≤ 50kPa, 
    Q = π(D/2)²v = 0.05m³/s
    0.05m ≤ D ≤ 0.5m, 0.5m/s ≤ v ≤ 8m/s
    

Chained Problem Solving

USolver's killer feature? Chaining solvers across domains. Consider a restaurant optimization:

  1. OR-Tools first computes table layout:
    maximize seats 
    subject to: 4m²×T₂ + 6m²×T₄ + 9m²×T₆ ≤ 150m²
    T₂≥2, T₄≥3, T₆≥1, ΣT≤20
  2. CVXPY then optimizes staff scheduling:
    minimize labor cost
    subject to: staff ≥ max(2, seats/20)

Integration and Deployment

Install via uv run install.py for Claude/Cursor integration or deploy via Docker:

docker run -p 8081:8081 ghcr.io/sdiehl/usolver:latest

Client configuration simply references the MCP server endpoint.

Why This Matters

Traditionally, leveraging these solvers required deep expertise in mathematical programming. USolver democratizes access by letting developers describe problems naturally while handling:
- Automatic constraint generation
- Solver selection
- Result interpretation

As optimization becomes critical in logistics, finance, and AI training, tools like USolver could reshape how engineers interface with computational mathematics—transforming dense equations into solvable prompts.

Source: USolver GitHub Repository