ortools-mcp
Click on "Install 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., "@ortools-mcpfix OCR errors in invoice data using equations total = quantity * rate"
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.
ortools-mcp
An MCP server that exposes Google OR-Tools CP-SAT as tools for constraint-based value correction. Given a set of equations and observed variable values, it finds the minimal corrections needed to make everything consistent.
Use case: you have values extracted from a document (OCR, form parsing, etc.) that should satisfy known equations (e.g. total = quantity × rate + tax), but one or more values were misread. The solver finds which values to adjust and by how much, weighted by how much you trust each observation.
Tools
solve
Runs CP-SAT. Returns corrected values for free (non-fixed) variables that best satisfy the given equations.
Input
{
"variables": {
"gross_amount": {
"obs": 500,
"confidence": 0.3,
"mult_factor": 100,
"min": 0,
"max": 100000,
"fixed": false
},
"quantity": {
"obs": 10,
"mult_factor": 1,
"fixed": true
},
"rate_per_pc": {
"obs": 52,
"mult_factor": 100,
"fixed": true
}
},
"equations": [
{
"lhs": "gross_amount",
"rhs": "quantity * rate_per_pc",
"relation": "==",
"weight": 1000,
"tolerance": 0
}
],
"timeout_seconds": 5,
"num_workers": 8
}Output
{
"status": "OPTIMAL",
"corrected": {
"gross_amount": 520.0
}
}Only free (non-fixed) variables appear in corrected. Status values: OPTIMAL, FEASIBLE, INFEASIBLE, UNKNOWN, INVALID_EQUATION.
Variable spec fields
Field | Type | Default | Description |
| number | — | Observed (extracted) value in real-world units |
| 0–1 |
| How much to trust |
| int |
| Scales float values to integers for the solver ( |
| number |
| Domain bounds in real-world units |
| bool |
| Pin this variable to |
Equation fields
Field | Type | Default | Description |
| string | required | Left-hand side expression |
| string | required | Right-hand side expression |
|
| required | Relation between lhs and rhs |
| int |
| Penalty per unit of violation — higher means the solver tries harder to satisfy this equation |
| int |
| Allowed slack (in scaled integer units) before penalty kicks in |
Solver params
Field | Default | Description |
|
| Wall-clock limit for the solver |
|
| Parallel search workers |
validate_equations
Pure AST check — no solver invoked. Call this before solve to catch unsupported constructs early.
Input
{
"equations": [
{ "lhs": "total", "rhs": "taxable + tax" },
{ "lhs": "discount", "rhs": "-base * 0.1" }
]
}Output
[
{ "lhs": "total", "rhs": "taxable + tax", "errors": [] },
{
"lhs": "discount",
"rhs": "-base * 0.1",
"errors": [
"Unary operator 'USub' not supported in '-base * 0.1'. Rewrite e.g. '-x' as '(0 - x)'."
]
}
]Empty errors list means the equation is valid. Catches:
Unary negation (
-x) and unary plus (+x) — rewrite as(0 - x)Non-constant or zero/negative exponents in
**— onlyx ** 2,x ** 3, etc. are supportedSyntax errors
evaluate_equations
Evaluates equations against known values and returns pass/fail per equation. No OR-Tools involved — useful to check whether values already satisfy the system before deciding to call solve.
Input
{
"equations": [
{ "lhs": "gross_amount", "rhs": "quantity * rate_per_pc", "relation": "==", "tolerance": 0.5 }
],
"values": {
"gross_amount": 520,
"quantity": 10,
"rate_per_pc": 52
}
}Output
[
{
"lhs": "gross_amount",
"rhs": "quantity * rate_per_pc",
"status": "passed",
"actual": 520,
"computed": 520,
"error": 0.0
}
]Status values: passed, failed, missing_values (variable not in values), error (evaluation exception).
Related MCP server: Google OR-Tools server
Supported expression syntax
Both lhs and rhs accept arithmetic expressions over variable names and numeric constants:
Operator | Example | Notes |
|
| |
|
| Binary only — |
|
| |
|
| RHS divisions are automatically moved to LHS to avoid integer-division loss |
|
| Modulo |
|
| Exponent must be a constant positive integer |
Parentheses |
|
mult_factor and integer scaling
OR-Tools CP-SAT works only with integers. mult_factor scales real-world float values to integers before solving and divides back on return.
Amount fields (prices, totals):
mult_factor: 100— values like52.30become5230internallyQuantity fields:
mult_factor: 1— must stay at 1 for multiplicative equations
Why quantities must use mult_factor: 1: for gross = qty × rate, scaling all three by 100 gives gross×100 = (qty×100) × (rate×100), which is off by 100×. With qty at ×1: gross×100 = (qty×1) × (rate×100) — correct.
tolerance is expressed in scaled integer units (after mult_factor is applied). For mult_factor: 100, a tolerance of 200 means ±2.00 in real units.
Setup
pip install -r requirements.txtAdd to Claude Code (~/.claude/settings.json):
{
"mcpServers": {
"ortools-solver": {
"command": "python3",
"args": ["/path/to/ortools-mcp/server.py"]
}
}
}Running tests
pip install pytest
pytest test_solver.py test_server.py -vtest_server.py mocks the mcp package so it runs without needing mcp installed. 50 tests total covering all three tools, expression validation, scaling, confidence weighting, tolerance, and inequality constraints.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/iam-aditya/ortools-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server