mcp-solver
local-only server
The server can only run on the client’s local machine because it depends on local resources.
MCP Solver
A Model Context Protocol (MCP) server that exposes SAT, SMT and constraint solving capabilities to Large Language Models.
Overview
The MCP Solver integrates SAT, SMT and Constraint Solving with LLMs through the Model Context Protocol, enabling AI models to interactively create, edit, and solve:
For a detailed description of the MCP Solver's system architecture and theoretical foundations, see the accompanying research paper: Stefan Szeider, "MCP-Solver: Integrating Language Models with Constraint Programming Systems", arXiv:2501.00539, 2024.
Available Tools
In the following, item refers to some part of the (MinZinc/Pysat/Z3) code, and model to the encoding.
Tool Name | Description |
---|---|
clear_model | Remove all items from the model |
add_item | Add new item at a specific index |
delete_item | Delete item at index |
replace_item | Replace item at index |
get_model | Get current model content with numbered items |
solve_model | Solve the model (with timeout parameter) |
System Requirements
- Python and project manager uv
- Python 3.11+
- Mode-specific requirements: MiniZinc, PySAT, Python Z3 (required packages are installed via pip)
- Operating systems: macOS, Windows, Linux (with appropriate adaptations)
Installation
MCP Solver requires Python 3.11+, the uv
package manager, and solver-specific dependencies (MiniZinc, Z3, or PySAT).
For detailed installation instructions for Windows, macOS, and Linux, see INSTALL.md.
Quick start:
Available Modes / Solving Backends
The MCP Solver provides three distinct operational modes, each integrating with a different constraint solving backend. Each mode requires specific dependencies and offers unique capabilities for addressing different classes of problems.
MiniZinc Mode
MiniZinc mode provides integration with the MiniZinc constraint modeling language with the following features:
- Rich constraint expression with global constraints
- Integration with the Chuffed constraint solver
- Optimization capabilities
- Access to solution values via
get_solution
Dependencies: Requires the minizinc
package (uv pip install -e ".[mzn]"
)
Configuration: To run in MiniZinc mode, use:
PySAT Mode
PySAT mode allows interaction with the Python SAT solving toolkit with the following features:
- Propositional constraint modeling using CNF (Conjunctive Normal Form)
- Access to various SAT solvers (Glucose3, Glucose4, Lingeling, etc.)
- Cardinality constraints (at_most_k, at_least_k, exactly_k)
- Support for boolean constraint solving
Dependencies: Requires the python-sat
package (uv pip install -e ".[pysat]"
)
Configuration: To run in PySAT mode, use:
Z3 Mode
Z3 mode provides access to Z3 SMT (Satisfiability Modulo Theories) solving capabilities with the following features:
- Rich type system: booleans, integers, reals, bitvectors, arrays
- Constraint solving with quantifiers
- Optimization capabilities
- Template library for common modeling patterns
Dependencies: Requires the z3-solver
package (uv pip install -e ".[z3]"
)
Configuration: To run in Z3 mode, use:
MCP Test Client
The MCP Solver includes an MCP client for development, experimentation, and diagnostic purposes, based on the ReAct agent framework. This client serves as an intermediary between an LLM and the MCP server, facilitating the translation of natural language problem statements into formal constraint programming solutions.
Installation
The client requires an API key from an LLM provider. For Anthropic (the default LLM is Claude Sonnet 3.7), set the ANTHROPIC_API_KEY
environment variable. This can be set in your environment or included in a .env
file in the project root.
Usage
The client provides specialized commands for each solver backend:
Examples
Example 1: Casting Problem (MiniZinc)
This is based on an example by George Johnson (NYT, July 13, 1999).
User
Suppose that a theatrical director feels obligated to cast either his ingenue, Actress Alvarez, or his nephew, Actor Cohen, in a production. But Miss Alvarez won't be in a play with Mr. Cohen (her former lover), and she demands that the cast include her new flame, Actor Davenport. The producer, with her own favors to repay, insists that Actor Branislavsky have a part. But Mr. Branislavsky won't be in any play with Miss Alvarez or Mr. Davenport. Can the director cast the play?
System: clear_model
Copy
System: add_item
(multiple)
Copy
System: solve_model
Copy
The solution (cast Cohen and Branislavsky, but not Alvarez or Davenport) satisfies all constraints.
Example 2: N-Queens Problem (MiniZinc)
User
Check whether you can place n Queens on an nxn chessboard. Try n=10,20,30,40 and compare the solving times
System: clear_model
Copy
System: add_item
(multiple)
Copy
System: solve_model
(with n=10, 20, 30, and 40 by changing the value of n)
Solve times comparison: n=10: 0.001s n=20: 0.005s n=30: 0.040s n=40: 0.043s
Solutions exist for all tested board sizes. Time complexity increases non-linearly but remains manageable up to n=40.
Example 3: Traveling Salesperson Problem (MiniZinc)
User
A saleswoman based in Vienna needs to plan her upcoming tour through Austria, visiting each province capital once. Help find the shortest route. Distances in km: 1=Vienna, 2=St. Pölten, 3=Eisenstadt, 4=Linz, 5=Graz, 6=Klagenfurt, 7=Salzburg, 8=Innsbruck, 9=Bregenz
[Distance matrix table provided in user message]
System: add_item
(multiple)
Copy
System: solve_model
Copy
Optimal route: Vienna → St. Pölten → Linz → Salzburg → Bregenz → Innsbruck → Klagenfurt → Graz → Eisenstadt → Vienna with a total distance of 1,564 km.
Feedback
You can provide feedback to the author via this form.
Disclaimer
This MCP Solver is in its prototype stage and should be used with caution. Users are encouraged to experiment, but any use in critical environments is at their own risk.
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
A Model Context Protocol (MCP) server that exposes MiniZinc constraint solving capabilities to Large Language Models.