SM

szeider/mcp-solver

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

187 stars 23 forks 质量 83 趋势 20MIT

szeider/mcp-solver 是从 https://github.com/szeider/mcp-solver. 导入的 MCP 服务器候选

概览

szeider/mcp-solver 是从 https://github.com/szeider/mcp-solver. 导入的 MCP 服务器候选

概述(AI 翻译)

一个用于约束求解的MCP服务器(SAT、MaxSAT、SMT、CP、ASP、DP)。它转动了 连接的LLM主机转为求解器编写代理:主机获得一个Python版本 内核预装了真实求解器库,建模指令用于 选择后端,以及一个提交门。主机负责编码问题,运行 并与实求解器进行验证,提交最终程序—— 结果是解加上经过验证的求解程序 它。

版本4是一次全面的架构重构。 MCP接口和 求解引擎发生了变化;SAT 2025试卷(v3)的设计依然沿用至今 在 v3 分支。 见下方“从v3到v4”。

MCP服务器

mcp-solver-serve 运行在 stdio 上,并可与任何 MCP 主机合作:Claude 桌面、Claude代码、光标,或者你自己的客户端。主机LLM负责 自我求解——服务器是一个求解工具包;它不运行大型语言模型,需要 无API密钥:

  • select_backend(solver) 建立一个持久的IPython内核,使用 后端的求解器库和辅助函数,并返回建模 该后端的指令。再次调用会回收内核 下一个问题。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Solver

MCP Solver is an MCP server for constraint solving with SAT, MaxSAT, SMT, constraint programming, answer set programming and dynamic programming. You describe a problem in plain words to your MCP host, such as Claude Desktop or Claude Code. The host’s language model writes a Python program for one of six backends, each built on a solver library, and runs it in a kernel, a Python process that the server starts. When the host submits the program, the server runs it once more on its own, and you get the solution as JSON together with the program.

This is version 4. Version 3, described in the SAT 2025 paper, works differently (see From v3 to v4). To connect the server to your host, see Quick start.

Example

The following small scheduling problem is shortened from tests/problems/clingo/shift_assignment.md. The run below solved it with the clingo backend (answer set programming).

Assign two employees, Anna and Ben, to three shifts: morning, afternoon, evening. Each shift gets exactly one employee, and nobody works more than two shifts. Anna prefers all three shifts, Ben only the morning. Maximize the number of shifts that go to an employee who prefers them. Return JSON with satisfiable, assignment and satisfied_preferences.

The program printed this solution:

{"satisfiable": true, "assignment": {"afternoon": "anna", "evening": "anna", "morning": "ben"}, "satisfied_preferences": 3}

The submitted program has 98 lines. This excerpt shows its shape:

import json
import itertools
import clingo

# ... 6 lines: EMPLOYEES, SHIFTS and PREFERENCES, the instance data
ASP_RULES = """
1 { assigned(Shift,Employee) : employee(Employee) } 1 :- shift(Shift).
:- employee(Employee), 3 { assigned(Shift,Employee) : shift(Shift) }.
satisfied(Shift) :- assigned(Shift,Employee), prefers(Employee,Shift).
preference_score(Score) :- Score = #count { Shift : satisfied(Shift) }.
#maximize { 1,Shift : satisfied(Shift) }.
"""

# ... 2 lines: quote(value) writes a name as a quoted string for clingo

def solve():
在 GitHub 查看完整 README

安装

uvx --python 3.14 --from agentic-mcp-solver[agent
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mcp-solver": { "command": "uvx", "args": ["--python", "3.14", "--from", "agentic-mcp-solver[agent]", "mcp-solver-serve"] } } }