rikarazome avatar

Prolog Reasoner

rikarazome/prolog-reasoner

Connects Claude to SWI-Prolog for formal logic execution during conversation. Exposes execute_prolog for running arbitrary Prolog code plus four rule base tools for saving and reusing domain rules across calls. The LLM translates natural language problems into Prolog, Prolog handles the combinatorial search, and you get transparent reasoning you can inspect and debug. Includes CLP(FD) support for constraint problems and an optional proof tracer. Ships as both an MCP server (no API key needed) and a Python library with self-correction loops. Benchmarks show 90% accuracy on logic problems versus 73% for Claude alone. Reach for this when you need reliable multi-step inference, constraint satisfaction, or exhaustive search that LLMs struggle with natively.

GitHub stars
8
tools
5
transport
STDIO
last updated
Apr 17, 2026

Tools

5 tools

Public tool metadata for what this MCP can expose to an agent.

execute_prologRuns Prolog code written by the connected LLM and returns the query results.

Runs Prolog code written by the connected LLM and returns the query results.

No parameter schema in public metadata yet.

list_rule_basesReturn all saved rule bases with name, description, and tags.

Return all saved rule bases with name, description, and tags.

No parameter schema in public metadata yet.

get_rule_baseReturn the raw Prolog source of a saved rule base.

Return the raw Prolog source of a saved rule base.

No parameter schema in public metadata yet.

save_rule_baseWrite or overwrite a rule base.

Write or overwrite a rule base.

No parameter schema in public metadata yet.

delete_rule_baseRemove a saved rule base.

Remove a saved rule base.

No parameter schema in public metadata yet.

Sponsors

Readme

prolog-reasoner

PyPI version Python versions CI License: MIT

SWI-Prolog as a "logic calculator" for LLMs — available as an MCP server and a Python library. Eliminate the black box from LLM logical reasoning.

LLMs excel at natural language but struggle with formal logic. Prolog excels at logical reasoning but can't process natural language. prolog-reasoner bridges this gap by exposing SWI-Prolog execution to LLMs.

Does it help?

On the built-in 30-problem logic benchmark:

PipelineAccuracy
LLM-only (claude-sonnet-4-6)22/30 (73.3%)
LLM + prolog-reasoner27/30 (90.0%)

View the full README on GitHub

Details

Repository
github.com/rikarazome/prolog-reasoner
Package
prolog-reasoner
Transport
STDIO
Registry
MCP registry, active