MCP HubMCP Hub
szeider

mcp-solver

by: szeider

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

54created 14/12/2024
Visit
optimization
solving

📌Overview

Purpose: The MCP Solver aims to integrate MiniZinc constraint programming capabilities with Large Language Models (LLMs) via the Model Context Protocol, facilitating AI-driven model management and solution processes.

Overview: The MCP Solver provides an interface for LLMs to create, edit, validate, and solve constraint models while managing solution insights and model modifications through a memo system. It is designed for use with MiniZinc and supports various operating systems, making it versatile for different environments.

Key Features:

  • Finite Domain and Global Constraint Support: Enables the use of diverse constraints in model creation and solving.

  • Asynchronous Solving with Configurable Timeouts: Improves performance and allows for flexible solving depending on the complexity of constraints.

  • Item-based Model Editing: Enhances robustness by validating each model item individually, ensuring accurate and reliable modifications.

  • Solution State Management: Keeps track of the current state of solutions to facilitate updates and validations in real-time.

  • Knowledge Base Maintenance: Manages insights and solver information effectively through a memo system, aiding in the process of continuous learning and adaptation for the AI.


MCP Solver

A Model Context Protocol (MCP) server that exposes MiniZinc constraint solving capabilities to Large Language Models.


Overview

The MCP Solver integrates MiniZinc constraint programming with LLMs through the Model Context Protocol, enabling AI models to:

  • Create, edit, and validate constraint models
  • Execute constraint solving operations
  • Access and update solution knowledge
  • Manage solver insights through a memo system

For a detailed description of the system architecture and theoretical foundations, refer to the research paper: MCP-Solver: Integrating Language Models with Constraint Programming Systems.

Feedback

You can provide feedback to the author via this form.

Features

  • Finite domain and global constraint support
  • Asynchronous solving with configurable timeouts
  • Item-based model editing
  • Solution state management
  • Knowledge base maintenance

Available Tools

Model modification has transitioned to an item-based editing approach for improved robustness. Each model modification operation returns the current model with numbered items.

Tool NameDescription
get_modelGet current model content with numbered items
add_itemAdd new item at specific index
delete_itemDelete item at index
replace_itemReplace item at index
clear_modelClear all items in the model
solve_modelSolve the model with the Chuffed constraint solver
get_solutionGet specific variable value from solution with optional array indices
get_solve_timeGet last solve execution time
get_memoGet current knowledge base
edit_memoEdit knowledge base

System Requirements

  • Python 3.11+
  • MiniZinc with the Chuffed solver
  • Compatible operating systems: macOS, Windows, Linux

Installation

  1. Install an MCP-compatible client (e.g., Claude web interface or desktop app).

  2. Install the MCP Solver:

    git clone https://github.com/szeider/mcp-solver.git
    cd mcp-solver
    uv pip install -e .
    
  3. Create the configuration file based on your operating system.

    For macOS/Linux:

    Create at:

    ~/Library/Application/Support/Claude/claude_desktop_config.json
    

    Add the following content:

    {
      "mcpServers": {
        "MCP Solver": {
          "command": "uv",
          "args": [
            "--directory", 
            "/absolute/path/to/mcp-solver",  
            "run", 
            "mcp-solver"
          ]
        }
      }
    }
    

    For Windows:

    Create at:

    %APPDATA%\Claude\claude_desktop_config.json
    

    Add the following content:

    {
      "mcpServers": {
        "MCP Solver": {
          "command": "cmd.exe",
          "args": [
            "/C",
            "cd C:\\absolute\\path\\to\\mcp-solver && uv run mcp-solver"
          ]
        }
      }
    }
    
  4. Test the setup with:

    uv run test-setup
    

Lite Mode

MCP Solver supports a Lite Mode with essential tools:

  • clear_model
  • add_item
  • replace_item
  • delete_item
  • solve_model
  • get_model

In this mode, solve_model returns the status of the solution (e.g., SAT or UNSAT). To use Lite Mode, add the --lite flag to your command.


Examples

Casting Example

Theater casting problem modeled using MiniZinc.

  1. User describes the casting constraints.
  2. LLM models the problem with MiniZinc commands.
  3. The solution concludes which actors can be cast.

N-Queens Example

Checks whether n queens can be placed on a chessboard with various configurations (n=10, 20, 30, 40).

  1. User requests the queen placement for various n values.
  2. LLM creates and modifies the model dynamically.
  3. The solve times and configurations are reported.

Traveling Salesperson Problem (TSP)

A saleswoman's optimal route through Austria is calculated.

  1. User describes the problem with distance between locations.
  2. LLM models the problem and finds the shortest route.
  3. Adjusted a route based on blockage and recalculates the new optimal tour.

Disclaimer

This MCP Solver is in its prototype stage and should be used with caution. Experimentation is encouraged, but use in critical environments is at your own risk.


Changelog

See the 1 for details on version history and changes.


License

This project is licensed under the MIT License - see the LICENSE file for details.