home / mcp / szeider mcp solver

Szeider MCP Solver

Model Context Protocol (MCP) server for constraint optimization and solving"

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "szeider-mcp-solver": {
      "command": "mcp-solver-mzn",
      "args": []
    }
  }
}

You can run the MCP Solver to interactively build and solve constraint models using specialized backends such as MiniZinc, PySAT, MaxSAT, Z3, and ASP, all orchestrated through the Model Context Protocol to work with large language models. This server lets you create, edit, and solve constraint problems with a consistent interface, enabling you to switch solvers as needed while keeping problem definitions in familiar formats.

How to use

Choose a solver mode that matches your problem type and start the corresponding MCP server command. Once the server is running, you can interact with it through the MCP client or your preferred integration layer to construct and modify a model step by step, and then request a solve with a single command.

How to install

Prerequisites: you need Python 3.11 or newer and the uv package manager.

Install Python dependencies and enable virtual environment, then install all MCP solvers.

Step-by-step commands you should run:

git clone https://github.com/szeider/mcp-solver.git
cd mcp-solver
uv venv
source .venv/bin/activate
uv pip install -e ".[all]"  # Install all solvers

Additional sections

MCP modes and how to run them: MiniZinc mode runs the MiniZinc-backed solver via the following entry point, PySAT mode uses the PySAT backend, MaxSAT mode enables weighted satisfiability optimization, Z3 mode provides SMT solving with Z3, and ASP mode uses Clingo for answer-set programming.

MCP mode commands to start:

mcp-solver-mzn
mcp-solver-pysat
mcp-solver-maxsat
mcp-solver-z3
mcp-solver-asp

Client integration: You can install and run the MCP Test Client to translate natural language problem statements into formal models and forward them to the MCP server. To install the client dependencies and verify setup, run the following:

uv pip install -e ".[client]"
uv run test-setup-client

Notes on usage and troubleshooting

An API key is required for the MCP client to access an LLM provider. Set the ANTHROPIC_API_KEY environment variable or configure an alternative provider as needed. The client supports multiple providers, including Anthropic, OpenAI, Gemini, OpenRouter, and local models, selectable with a command-line flag.

Tools available in the MCP Solver include commands to manage and interact with the model: clear_model, add_item, delete_item, replace_item, get_model, and solve_model. Use clear_model to reset the active model, add_item to insert constraints or problem elements, and solve_model to compute a solution.

Security and environment considerations

Run MCP modes in trusted environments and avoid exposing API keys or internal solver URLs. When using the client, ensure that keys and secrets are stored securely and not committed to public repositories.

Examples of typical workflow

1) Start a solver mode (for example MiniZinc): run mcp-solver-mzn.

2) Build a model by adding items with the MCP client or equivalent interface.

3) Request a solve and review the solution values returned by the solver.

4) Modify items and re-solve to explore alternative solutions or optimize the objective.

Examples and reference backends

The MCP Solver provides backends for MiniZinc, PySAT, MaxSAT, Z3, and ASP. Each backend supports its own modeling constructs and constraints, yet you interact with them through a consistent MCP interface to add, replace, or remove items and to request solutions.

Troubleshooting tips

If a solver mode fails to start, verify that Python 3.11+ and the uv toolchain are installed, and that the required solver-specific dependencies are installed via the provided installation commands. Ensure you are using the correct mode command for the problem type and that any necessary environment variables are set before launching the client.

Notes on the MCP project

This MCP Solver supports constraint solving, SAT, SMT, and ASP capabilities to facilitate interactive problem solving with language models. It provides a standardized set of tools to manage models and a range of backends to address different classes of problems.

Available tools

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)