MCP server for interacting with Clingo ASP solver via WebAssembly
solve: Run an ASP program and get answer sets
addToProgram: Add facts/rules to current session
clearProgram: Clear the current session
getProgram: View the current program
saveSession: Persist program to disk
loadSession: Restore previous sessions
json
{
"mcpServers": {
"clingo-mcp": {
"command": "node",
"args": [
"clingo-mcp/dist/index.js"
],
"disabled": false,
"alwaysAllow": [
"solve",
"addToProgram",
"clearProgram",
"getProgram",
"saveSession",
"loadSession"
],
"timeout": 30
}
}
}
`
Development:
`bash
git clone https://github.com/NewJerseyStyle/clingo-mcp
cd clingo-mcp
npm install
npm run build
`
Example ASP Program:
`asp
% 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.
`
Example Usage:
`javascript
// Using the solve tool
const result = await solve({
program: "a. b :- a. {c; d}.",
models: 0 // 0 = all models
});
``