MCP-Logic
The MCP-Logic server is built with Python and integrates with Prover9/Mace4 to provide automated reasoning capabilities for AI systems through a clean MCP interface.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP-Logicprove that all men are mortal and Socrates is a man implies Socrates is mortal"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP-Logic
An MCP server for automated first-order logic reasoning using Prover9, Mace4, and an onboard reasoning LLM.
Features
Theorem Proving - Prove logical statements with Prover9
Model Finding - Find finite models with Mace4
Counterexample Finding - Show why statements don't follow
Syntax Validation - Pre-validate formulas with helpful error messages
Categorical Reasoning - Built-in support for category theory proofs
Propositional Contingency - Purely analytical HCC prover for fast propositional checks
Abductive Reasoning - Rank hypotheses using Variational Free Energy (VFE)
š¤ Logic Advisor (NEW) - Onboard TwIL-LM3 reasoning LLM that solves logic problems end-to-end: just ask a question in plain English
Self-Contained - All dependencies install automatically
Related MCP server: warrant-mcp
Quick Start
Installation
Linux/macOS:
git clone https://github.com/angrysky56/mcp-logic
cd mcp-logic
./linux-setup-script.shWindows:
git clone https://github.com/angrysky56/mcp-logic
cd mcp-logic
windows-setup-mcp-logic.batThe setup script automatically:
Downloads and builds LADR (Prover9 + Mace4)
Creates Python virtual environment
Installs all dependencies
Generates Claude Desktop config
Enable the Logic Advisor (Optional)
The onboard logic advisor uses a local 3B-parameter LLM (TwIL-LM3 Q8) to solve logic problems end-to-end. Run the setup script to install it:
Linux/macOS:
./setup-advisor.shWindows:
setup-advisor.batThe script automatically:
Detects your GPU ā CUDA on NVIDIA (Linux/Windows), Metal on Apple Silicon (macOS), or falls back to CPU
Compiles
llama-cpp-pythonwith the right acceleration backendDownloads the model (~3.3 GB, one-time) to
~/.cache/mcp-logic/models/
No venv activation needed ā the setup scripts use
uvwhich manages the virtual environment automatically. Alluv runanduv pip install --directorycommands target the project's.venvwithout you having to activate it first.
Manual Installation (Advanced)
If you prefer to install manually instead of using the setup script:
Linux (NVIDIA GPU):
CMAKE_ARGS="-DGGML_CUDA=on" uv pip install --directory . "llama-cpp-python>=0.3.0"
uv pip install --directory . "huggingface-hub>=0.24.0"macOS (Apple Silicon):
CMAKE_ARGS="-DGGML_METAL=on" uv pip install --directory . "llama-cpp-python>=0.3.0"
uv pip install --directory . "huggingface-hub>=0.24.0"Windows (NVIDIA GPU, PowerShell):
$env:CMAKE_ARGS="-DGGML_CUDA=on"
uv pip install --directory . "llama-cpp-python>=0.3.0"
uv pip install --directory . "huggingface-hub>=0.24.0"CPU-only (any platform):
uv pip install --directory . "llama-cpp-python>=0.3.0"
uv pip install --directory . "huggingface-hub>=0.24.0"The model auto-downloads on first use, or pre-download manually:
uv run --directory . python -c "
from huggingface_hub import hf_hub_download
hf_hub_download('webAI-Official/TwIL-LM3', 'TwIL-LM3-Q8_0.gguf',
revision='5d90f3a3251e142fc5cc6b42a62b175fdb0d4ccd',
local_dir='$HOME/.cache/mcp-logic/models',
local_dir_use_symlinks=False)
"Platform Compatibility
Platform | GPU Acceleration | Notes |
Linux (x86_64) | ā CUDA (NVIDIA) | Requires CUDA Toolkit + |
macOS (Apple Silicon) | ā Metal | Native ARM64 Python recommended |
macOS (Intel) | ā ļø Metal (limited) | Works but slower than Apple Silicon |
Windows (x86_64) | ā CUDA (NVIDIA) | Requires CUDA Toolkit + Visual Studio Build Tools |
Any platform | ā CPU | Always works, slower (~10-20s per query for 3B model) |
Claude Desktop Integration
Add to your Claude Desktop MCP config (auto-generated at claude-app-config.json):
{
"mcpServers": {
"mcp-logic": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-logic",
"run",
"mcp_logic",
"--prover-path",
"/absolute/path/to/mcp-logic/ladr/bin"
]
}
}
}Important: Replace /absolute/path/to/mcp-logic with your actual repository path.
Add "--no-advisor" for deterministic solver-only testing or when the
optional advisor dependencies are not installed. The model is lazy-loaded, so
normal prove and find_model calls do not consume GPU memory.
Codex Integration
Register the stdio server globally with absolute paths:
codex mcp add mcp-logic -- \
/absolute/path/to/mcp-logic/.venv/bin/mcp_logic \
--prover-path /absolute/path/to/mcp-logic/ladr/binConfirm the saved command with codex mcp get mcp-logic. Restart Codex after
adding or changing the server so its tools are loaded into the next session.
Available Tools
Tool | Purpose |
ask_logic_advisor š¤ | Solve logic problems in plain English (end-to-end) |
prove | Prove statements using Prover9 |
check_well_formed | Validate formula syntax with detailed errors |
find_model | Find finite models satisfying premises |
find_counterexample | Find counterexamples showing statements don't follow |
verify_commutativity | Generate FOL for categorical diagram commutativity |
get_category_axioms | Get axioms for category/functor/group/monoid |
check_contingency | Check truth-functional contingency via HCC prover |
abductive_explain | Find the VFE-minimizing explanation for an observation |
Example Usage
Ask the Logic Advisor (Easiest)
Just ask a question in natural language ā the advisor formalizes it, runs the solver, and explains the result:
Use ask_logic_advisor with:
question: "Is it true that if all humans are mortal and Socrates is human,
then Socrates is mortal?"Result: The advisor translates to FOL, proves the theorem with Prover9, and returns:
"Yes, Socrates is mortal. The proof follows from the universal premise that all humans are mortal, combined with the fact that Socrates is human."
The response also includes the formalization it used and the raw solver output for transparency.
Prove a Theorem (Direct)
Use the prove tool with:
premises: ["all x (man(x) -> mortal(x))", "man(socrates)"]
conclusion: "mortal(socrates)"Result: ā THEOREM PROVED
Analyze Propositional Contingency
Use the check_contingency tool with:
formula: "(p -> q) | (q -> p)"Result: Identifies that the formula is a non-contingent tautology, returning the proof trace.
Find a Counterexample
Use the find_counterexample tool with:
premises: ["P(a)"]
conclusion: "P(b)"Result: Model found where P(a) is true but P(b) is false, proving the conclusion doesn't follow.
Verify Categorical Diagram
Use the verify_commutativity tool with:
path_a: ["f", "g"]
path_b: ["h"]
object_start: "A"
object_end: "C"Result: FOL premises and conclusion to prove that fāg = h.
Running Locally
Instead of Claude Desktop, run the server directly:
Linux/macOS:
./run_mcp_logic.shWindows:
run_mcp_logic.batProject Structure
mcp-logic/
āāā src/mcp_logic/
ā āāā server.py # Main MCP server (9 tools)
ā āāā logic_advisor.py # Onboard TwIL-LM3 agentic solver
ā āāā mace4_wrapper.py # Mace4 model finder
ā āāā syntax_validator.py # Formula syntax validation
ā āāā categorical_helpers.py # Category theory utilities
ā āāā hcc_prover.py # Hypersequent Contingency Calculus prover
ā āāā vfe_engine.py # Variational Free Energy abductive engine
ā āāā formula_ast.py # Propositional logic AST and parser
ā āāā fol_ast.py # First-order AST, parser, and transformations
āāā ladr/ # Auto-installed Prover9/Mace4 binaries
ā āāā bin/
ā āāā prover9
ā āāā mace4
āāā tests/ # Unit, solver integration, and MCP stdio tests
āāā linux-setup-script.sh # Linux/macOS core setup
āāā windows-setup-mcp-logic.bat # Windows core setup
āāā setup-advisor.sh # Linux/macOS advisor setup
āāā setup-advisor.bat # Windows advisor setup
āāā run_mcp_logic.sh # Linux/macOS run script
āāā run_mcp_logic.bat # Windows run scriptLogic Advisor Details
The ask_logic_advisor tool uses a 3-phase agentic pipeline:
Natural Language Question
ā
ā¼
āāāāāāāāāāāāāāāāāāāāāāā
ā 1. FORMALIZE ā TwIL-LM3 translates to FOL
ā (LLM call) ā ā {"tool":"prove", "premises":[...], ...}
āāāāāāāāāā¬āāāāāāāāāāāāā
ā¼
āāāāāāāāāāāāāāāāāāāāāāā
ā 2. EXECUTE ā Runs actual Prover9/Mace4/HCC
ā (Solver call) ā ā {"result":"proved", "proof":...}
āāāāāāāāāā¬āāāāāāāāāāāāā
ā¼
āāāāāāāāāāāāāāāāāāāāāāā
ā 3. INTERPRET ā TwIL-LM3 explains the result
ā (LLM call) ā ā Plain English answer
āāāāāāāāāāāāāāāāāāāāāāāModel: TwIL-LM3 (3B params, fine-tuned for formal reasoning)
Quantization: Q8_0 GGUF (~3.3 GB on disk, ~3.5 GB VRAM)
Lazy loading: Model loads on first query, not at server startup
License: webAI Non-Commercial License v1.0 (non-commercial use only)
Resource Requirements
Scenario | VRAM | Inference Speed |
NVIDIA GPU (CUDA) | ~3.5 GB | ~1-3s per LLM call |
Apple Silicon (Metal) | ~3.5 GB | ~2-5s per LLM call |
CPU-only | 0 (uses RAM) | ~10-20s per LLM call |
What's New in v0.4.0
Onboard Logic Advisor:
ā ask_logic_advisor tool: Solve logic problems in plain English ā the onboard TwIL-LM3 LLM formalizes, runs the solver, and interprets results automatically
ā Cross-platform GPU setup: Auto-detects CUDA (NVIDIA) or Metal (Apple Silicon) and compiles accordingly
ā Lazy model loading: No VRAM used until the advisor is first called
ā Auto-download: Model downloads from HuggingFace on first use
What's New in v0.3.0
Cognitive Architecture Enhancements:
ā Hypersequent Contingency Calculus (HCC): Added a rigorous deductive checker for evaluating propositional formula contingencies instantly without brute-force modeling.
ā Variational Free Energy (VFE) Engine: Implemented abductive reasoning that ranks hypotheses using a non-dogmatic Cournot-Gaifman prior to elegantly satisfy Ockham's Razor.
ā Smart Prover Routing:
provetool automatically routes pure propositional queries to the HCC engine, and first-order queries to Prover9.ā Configurable Model Finder:
find_modelandfind_counterexamplenow support custom timeouts and structured predicate/function extraction.ā Decidable Fragment Search: BSR and safely bounded monadic theories receive a complete
1..model_boundsearch. Ano_model_foundresponse is absolute only with a context-licensedPROVEDorREFUTEDstatus; aBOUNDED_NO_MODELresponse retains the finite-bound hedge.ā Theory-aware Advisor Routing: Solver selection follows parsed formula structure, including mixed arithmetic and uninterpreted predicates, rather than English keyword matching.
ā Variable-scope Lint:
check_well_formedwarns about implicit universal quantification and unused binders without rejecting legal Prover9 formulas.
What's New in v0.2.0
Enhanced Features:
ā Mace4 model finding and counterexample detection
ā Detailed syntax validation with position-specific errors
ā Categorical reasoning support (category theory axioms, commutativity verification)
ā Structured JSON output from all tools
ā Self-contained installation (no manual path configuration)
Development
The test fixtures automatically discover the bundled ladr/bin/prover9 and
ladr/bin/mace4; no LADR_PATH is needed for a normal checkout.
Run the complete suite:
.venv/bin/python -m pytest tests/ -qRun only the end-to-end MCP stdio test, which starts the server and exercises both Prover9 and Mace4 through MCP tool calls:
.venv/bin/python -m pytest tests/test_mcp_stdio_integration.py -qRestricted process sandboxes can allow the LADR binaries to start while preventing them from making progress, producing misleading 30/60-second timeouts. Run solver-backed tests outside that sandbox; do not compensate by increasing the solver timeout.
Documentation
mcp_logic_agent.md- Agent guide (tool reference + workflows)ENHANCEMENTS.md- Quick reference for v0.2.0 featuresDocuments/- Detailed analysis and examples
Troubleshooting
"Prover9 not found" error:
Run the setup script:
./linux-setup-script.shorwindows-setup-mcp-logic.batCheck that
ladr/bin/prover9andladr/bin/mace4exist
Logic advisor not working:
Run the advisor setup:
./setup-advisor.shorsetup-advisor.batCheck GPU detection:
nvidia-smi(Linux/Windows) orsystem_profiler SPDisplaysDataType(macOS)Force CPU mode:
./setup-advisor.sh --cpuCheck model exists:
ls ~/.cache/mcp-logic/models/TwIL-LM3-Q8_0.ggufDisable if not needed: add
--no-advisorto server args
"llama-cpp-python" build fails:
Linux: Install build tools:
sudo apt-get install build-essential cmakemacOS: Install Xcode tools:
xcode-select --installWindows: Install Visual Studio Build Tools with "Desktop development with C++" workload
CUDA: Ensure CUDA Toolkit is installed and
nvccis in PATH
Server not updating:
Restart server after code changes
Check logs for syntax errors
Syntax validation warnings:
Use lowercase for predicates/functions (e.g.,
man(x)notMan(x))Add spaces around operators for clarity
Balance all parentheses
License
MIT (mcp-logic server)
Note: The TwIL-LM3 model used by the logic advisor is licensed under the webAI Non-Commercial License v1.0. This restricts the advisor feature to non-commercial use. The core mcp-logic server (prove, find_model, etc.) remains MIT-licensed and usable commercially without the advisor.
Credits
Prover9/Mace4: William McCune's LADR library
LADR Repository: laitep/ladr
TwIL-LM3: webAI ā 3B reasoning model fine-tuned for formal logic
Hypersequent Contingency Calculus (HCC): Based on "A Hypersequent Calculus for Classical Contingencies" by Eugenio Orlandelli, Giannandrea Pulcini, and Achille C. Varzi (2024).
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceAn MCP server for the Pyke logic programming engine that enables LLMs to perform logical reasoning using knowledge bases with facts, rules, and queries. It supports session management, forward chaining inference, and bulk loading of programs in Logic-LLM format.MIT
- Flicense-qualityDmaintenanceAn MCP server that provides formal reasoning and argument validation tools for AI agents based on established computational argumentation theories. It enables structured argument analysis, defeasible reasoning, and dialogue management using frameworks like Dung, Toulmin, and Walton's schemes.
- AlicenseAqualityDmaintenanceMCP server that gives small LLMs verified symbolic-math & logic tools.62Apache 2.0
- AlicenseAqualityCmaintenanceAn MCP server for first-order logic theorem proving supporting multiple provers like Vampire, E, and Prover9, with built-in simple prover, session management, and TPTP export.131MIT
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server for AI dialogue using various LLM models via AceDataCloud
An MCP server that integrates with Discord to provide AI-powered features.
Appeared in Searches
- A server for finding information about Chinese metaphysics and mysticism
- Comparison of Python-based tools for converting TeX to Lean
- Tools for Converting LaTeX Mathematics to Lean Formalizations
- Recommended helper server for automating TeX to Lean conversions in GRAD-5 repository
- Tools and Systems for Math, AI, and Proof Verification with Bug Detection and Auto Fixing
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/angrysky56/mcp-logic'
If you have feedback or need assistance with the MCP directory API, please join our Discord server