Clingo MCP服务器
一个神经符号AI服务器,将Clingo的答案集编程(ASP)求解器与模型上下文协议(MCP)相结合,用于混合AI应用程序。
特征:
- 通过WebAssembly求解答案集编程
- 内存程序会话:逐步构建程序
- 会话管理:将ASP程序保存/加载到磁盘
- 六个核心工具:
- solve:运行ASP程序并获取答案集 - addToProgram:向当前会议添加事实/规则 - clearProgram:清除当前会话 - getProgram:查看当前程序 - saveSession:将程序持久化到磁盘 - loadSession:恢复以前的会话
- 通过Zod模式验证对所有I/O进行类型安全
- WebAssembly运行时:Clingo编译为WASM
与Cline/Roo/Copilot集成:
{
"mcpServers": {
"clingo-mcp": {
"command": "npx",
"args": ["clingo-mcp"],
"disabled": false,
"alwaysAllow": [
"solve",
"addToProgram",
"clearProgram",
"getProgram",
"saveSession",
"loadSession"
],
"timeout": 30
}
}
}发展:
git clone https://github.com/NewJerseyStyle/clingo-mcp
cd clingo-mcp
npm install
npm run buildASP程序示例:
% Define persons
person(alice).
person(bob).
person(carol).
% Define friendships
friend(alice, bob).
friend(bob, carol).
% Rule: friendship is symmetric
friend(X, Y) :- friend(Y, X).
% Rule: transitive friendship
indirect_friend(X, Z) :- friend(X, Y), friend(Y, Z), X != Z.示例用法:
// Using the solve tool
const result = await solve({
program: "a. b :- a. {c; d}.",
models: 0 // 0 = all models
});______________________________________________________________________
致谢:
