V-Sekai-fire's Minizinc

行业场景

by V-Sekai-fire

Solve constraint programming problems with MiniZinc.

什么是 V-Sekai-fire's Minizinc

Solve constraint programming problems with MiniZinc.

README

MiniZinc MCP Server

A Model Context Protocol (MCP) server that provides MiniZinc constraint programming capabilities.

Features

  • Solve MiniZinc models using HiGHS solver (LP/MIP with float support)
  • Validate MiniZinc models for syntax and type errors without solving
  • Support for both MZN (model) and DZN (data) content as strings
  • Automatic standard library inclusion (e.g., alldifferent.mzn) when not present in models
  • Comprehensive output format: Parses DZN format for variable extraction, passthroughs output_text from explicit output statements
  • JSON-RPC 2.0 protocol support via STDIO or HTTP transports
  • Server-Sent Events (SSE) support for streaming responses

Quick Start

Prerequisites

  • Elixir 1.18+
  • MiniZinc installed and available in PATH

Note: MiniZinc is automatically installed in the Docker image.

Installation

bash
git clone <repository-url>
cd minizinc-mcp
mix deps.get
mix compile

Usage

STDIO Transport (Default)

For local development:

bash
mix mcp.server

Or using release:

bash
./_build/prod/rel/minizinc_mcp/bin/minizinc_mcp start

HTTP Transport

For web deployments (e.g., Smithery):

bash
PORT=8081 MIX_ENV=prod ./_build/prod/rel/minizinc_mcp/bin/minizinc_mcp start

Endpoints:

  • POST / - JSON-RPC 2.0 MCP requests
  • GET /sse - Server-Sent Events for streaming
  • GET /health - Health check

Docker

bash
docker build -t minizinc-mcp .
docker run -d -p 8081:8081 --name minizinc-mcp minizinc-mcp

Tools

The server provides the following MCP tools:

minizinc_solve

Solve a MiniZinc model using the HiGHS solver (LP/MIP with float support).

Parameters

  • model_content (string, required): MiniZinc model content (.mzn) as string
  • data_content (string, optional): DZN data content as string (e.g., "n = 8;"). Must be valid DZN format. Parsed and included in response as input_data field.
  • timeout (integer, optional): Optional timeout in milliseconds (default: 30000, i.e., 30 seconds). Maximum allowed is 30000 ms (30 seconds); values exceeding this will be capped at 30 seconds.
  • auto_include_stdlib (boolean, optional): Automatically include standard MiniZinc libraries (e.g., alldifferent.mzn) if not present (default: true)
<details> <summary><strong>Output Format Details</strong></summary>

The minizinc_solve tool returns solutions as JSON in the following format:

  • DZN format parsing: When MiniZinc provides DZN format output (models without explicit output statements), variables are parsed and returned as structured data (e.g., {"x": 10, "y": [1, 2, 3]})
  • Output text passthrough: When models include explicit output statements, the output text is passthrough'd in the output_text field (e.g., {"output_text": "x = 10\n"})
  • Both formats: When both DZN and explicit output are available, both are included in the response
  • Input data: When data_content is provided, the parsed DZN data is included in the input_data field
  • Status: Solution status (e.g., "SATISFIED", "OPTIMAL_SOLUTION", "UNSATISFIABLE") is included when available

The response is always returned as a JSON string in the MCP content field.

</details> <details> <summary><strong>Standard Library Support</strong></summary>

The minizinc_solve tool automatically includes common MiniZinc standard libraries (e.g., alldifferent.mzn) if they are not already present in the model (when auto_include_stdlib is true). This means you can use standard functions like all_different without needing to add explicit include statements.

</details> <details> <summary><strong>Solve Tool Examples</strong></summary>

STDIO:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "minizinc_solve",
    "arguments": {
      "model_content": "var int: x; constraint x > 0; solve satisfy;"
    }
  }
}

HTTP:

bash
curl -X POST http://localhost:8081/ \
  -H "Content-Type: application/json" \
  -H "mcp-protocol-version: 2025-06-18" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "minizinc_solve", "arguments": {"model_content": "var int: x; constraint x > 0; solve satisfy;"}}}'

With data content:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "minizinc_solve",
    "arguments": {
      "model_content": "var int: n; array[1..n] of var int: x; constraint all_different(x); solve satisfy;",
      "data_content": "n = 8;",
      "timeout": 30000
    }
  }
}
</details>

minizinc_validate

Validate a MiniZinc model by checking syntax and type checking without solving. Useful for debugging models before attempting to solve them.

Parameters

  • model_content (string, required): MiniZinc model content (.mzn) as string
  • data_content (string, optional): DZN data content as string (e.g., "n = 8;"). Must be valid DZN format.
  • auto_include_stdlib (boolean, optional): Automatically include standard MiniZinc libraries (e.g., alldifferent.mzn) if not present (default: true)

Response Format

Returns a JSON object with:

  • valid (boolean): Whether the model is valid
  • errors (array): List of error messages (if any)
  • warnings (array): List of warning messages (if any)
  • message (string): Human-readable message (when valid)
  • raw_output (string): Raw MiniZinc validation output (when invalid)
<details> <summary><strong>Validate Tool Examples</strong></summary>

Validate a valid model:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "minizinc_validate",
    "arguments": {
      "model_content": "var int: x; constraint x > 0; solve satisfy;"
    }
  }
}

Response for valid model:

json
{
  "valid": true,
  "errors": [],
  "warnings": [],
  "message": "Model is valid"
}

Validate a model with syntax errors:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "minizinc_validate",
    "arguments": {
      "model_content": "var int: x; constraint x > 0 solve satisfy;"
    }
  }
}

Response for invalid model:

json
{
  "valid": false,
  "errors": [
    "Error: syntax error, unexpected solve, expecting ';'"
  ],
  "warnings": [],
  "raw_output": "..."
}
</details>

Configuration

Environment Variables:

  • PORT - HTTP server port (default: 8081)
  • HOST - HTTP server host (default: 0.0.0.0 if PORT set, else localhost)
  • MIX_ENV - Environment (prod, dev, test)
  • ELIXIR_ERL_OPTIONS - Erlang options (set to "+fnu" for UTF-8)
  • MCP_SSE_ENABLED - Enable/disable Server-Sent Events (default: true, set to "false" to disable)

The server uses HTTP streaming only (no stdio transport).

Troubleshooting

MiniZinc not found: Ensure MiniZinc is installed and available in PATH. For Docker, MiniZinc is included in the image.

Port already in use: Change PORT environment variable or stop conflicting services.

Compilation errors: Run mix deps.get && mix clean && mix compile.

Debug mode: Use MIX_ENV=dev mix mcp.server for verbose logging.

Version

Current version: 1.0.0-dev2 (see mix.exs for latest version)

Requirements

  • Elixir 1.18+
  • Erlang/OTP 26+
  • MiniZinc 2.9.3+ installed and available in PATH (or use Docker image which includes MiniZinc)
<details> <summary><strong>Development</strong></summary>

Building

bash
mix deps.get
mix compile

Testing

bash
mix test

Building Release

bash
MIX_ENV=prod mix release

Running Locally

For STDIO transport (default):

bash
mix mcp.server
bash
PORT=8081 mix run --no-halt
</details>

License

MIT License - see LICENSE.md for details.

Copyright

Copyright (c) 2025-present K. S. Ernest (iFire) Lee

常见问题

V-Sekai-fire's Minizinc 是什么?

Solve constraint programming problems with MiniZinc.

相关 Skills

面试体系设计

by alirezarezvani

Universal
热门

按岗位、级别和团队设计面试流程,生成能力矩阵、题库与评分标准,分析面试官偏差并校准招聘门槛,适合搭建或优化企业招聘体系。

团队招人没章法时,用它快速搭建岗位化面试流程、题库与评分标准,还能兼顾校准面试偏差,招聘更稳更准。

行业场景
未扫描18.5k

期权交易

by binance-skills-hub

热门

Binance Derivatives-trading-options request using the Binance API. Authentication requires API key and secret key. Supports testnet and mainnet.

行业场景
未扫描4.5k

A股交易助手

by alvisdunlop

热门

A股股票智能交易助手,专服务中国大陆股票市场。当用户询问A股股票行情、个股分析、大盘情绪、热点板块、交易策略、价格预警、涨跌幅、成交量、技术面或基本面分析时触发。只处理沪深A股(代码�?/00/30/68开头),自动忽略港股和美股。所有数据实时从东方财富、新浪财经、同花顺、雪球抓取。Use when: user asks about Chinese A-share stocks, 股票行情, 个股分析, 大盘分析, 板块热点, 买卖�? 止盈止损, 仓位建议, or any A-share trading-related query.

行业场景
未扫描4.5k

相关 MCP Server

by boosted-chat

热门

Flight search & booking for AI agents. 400+ airlines, $20-50 cheaper than OTAs.

行业场景
1.2k

检索韩国市场公司的披露文件与财务报表,并获取股票概况等关键信息。

想研究韩股公司时,它能一站式拉取披露、财报和股票概况,省去跨站查资料的麻烦,对跨境投研尤其省时。

行业场景
146

Search company disclosures and financial statements from the Korean market. Retrieve stock profiles, market classifications, and historical trading data across major exchanges. Accelerate equity research with accurate, date-specific insights for Korean securities.

做韩国股研时,用它能一站查公司披露、财报和历史行情,按日期精确追溯关键信息,比手动翻交易所高效太多。

行业场景
146

评论