References and builds upon Logic-LLM research published on arXiv for empowering language models with symbolic reasoning capabilities
Provides alternative installation method for the Clingo ASP solver dependency through the conda-forge channel
Integrates with GitHub repositories for development installation and accessing the Logic-LLM framework source code
Distributes the logic-lm-mcp-server package through PyPI for easy installation and dependency management
Logic-LM MCP Server
A Model Context Protocol (MCP) server that provides symbolic reasoning capabilities using Logic-LM framework and Answer Set Programming (ASP).
Attribution
This implementation is inspired by and builds upon the Logic-LLM framework:
Original Research:
Paper: Logic-LLM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning
Repository: teacherpeterpan/Logic-LLM
Authors: Liangming Pan, Alon Albalak, Xinyi Wang, William Yang Wang
This MCP server adapts the Logic-LLM approach for integration with Claude Code and other MCP clients, providing LLM-collaborative symbolic reasoning through Answer Set Programming.
š Quick Start
Prerequisites
Python 3.8 or higher
Installation
Choose your preferred installation method:
Option 1: Install from PyPI (Recommended) ā LIVE ON PYPI
š¦ Package URL: https://pypi.org/project/logic-lm-mcp-server/
Option 2: Install with Clingo solver (for full functionality)
Option 3: Development Installation
Test Installation
Integration with Claude Code
After installing the package, add it to your Claude Code configuration:
Method 1: Using the console command (after PyPI installation)
Method 2: Manual configuration
Edit ~/.config/claude/claude_desktop_config.json
(create if it doesn't exist):
Restart Claude Code to load the new MCP server.
Test the integration:
Try these commands in Claude Code:
Alternative Integration (Other MCP Clients)
For other MCP-compatible tools, start the server manually:
The server will run on stdio and provide these tools:
get_asp_guidelines
- Get ASP translation guidelinestranslate_to_asp_instructions
- Get problem-specific ASP guidanceverify_asp_program
- Execute ASP programs with Clingocheck_solver_health
- Verify system health
Overview
Logic-LM MCP Server converts natural language logical problems into Answer Set Programming (ASP) format, solves them using the Clingo solver, and returns human-readable results. It provides a three-stage reasoning pipeline: Problem Formulation ā Symbolic Reasoning ā Result Interpretation.
Features
Natural Language Input: Convert English logical problems to formal representations
ASP-Based Reasoning: Uses Answer Set Programming for robust logical inference
Clingo Integration: Leverages the Clingo ASP solver for symbolic reasoning
Self-Refinement: Iterative improvement of solutions through multiple reasoning passes
Template Library: Reusable ASP patterns for common logical structures
Fallback Handling: Graceful degradation when solver components unavailable
FastMCP Integration: Modern MCP server implementation with type safety
Tools Provided
1. get_asp_guidelines
Get comprehensive ASP translation guidelines (cached for efficiency).
Parameters: None
Returns: Complete ASP Logic Translation Guidelines document with comprehensive instructions for translating natural language into Answer Set Programming format.
2. translate_to_asp_instructions
Get lightweight instructions for translating a specific natural language problem to ASP.
Parameters:
problem
(string, required): Natural language logical problem to translate
Example:
Response:
3. verify_asp_program
Directly verify and solve an ASP program using the Clingo solver.
Parameters:
program
(string, required): ASP program code to verify and solvemax_models
(integer, 1-100, default: 10): Maximum number of models to find
Example:
4. check_solver_health
Check Logic-LM server and Clingo solver health status.
Returns:
Server status and component initialization status
Clingo availability and version information
System capabilities and configuration details
Basic functionality test results
Architecture
Core Components
LogicFramework: Main reasoning orchestrator
ClingoSolver: ASP solver interface and management
ASPTemplateLibrary: Reusable logical pattern templates
FastMCP Integration: Modern MCP server implementation
Processing Pipeline
Dependencies
Python 3.8+: Core runtime environment
FastMCP 2.0+: Modern MCP server framework
Pydantic 2.0+: Input validation and type safety
Clingo 5.8.0+: ASP solver (automatically detects if missing)
Installation
Option 1: Using pip
Option 2: Manual installation
Option 3: Development setup
Configuration
The server automatically handles:
Clingo solver installation detection
Template library loading
Environment-specific optimizations
Error recovery and fallback modes
Environment Variables
No environment variables required
Server runs with sensible defaults
Usage Examples
Basic Logical Reasoning
Syllogistic Reasoning
Set-Based Logic
Testing
Basic Functionality Test
Test MCP Integration
Error Handling
Clingo Unavailable: Provides informative error messages with installation guidance
Invalid ASP Programs: Syntax checking with detailed error messages
Solver Timeouts: Graceful handling of complex problems
Resource Constraints: Memory and time limit management
Performance
Simple Problems: 50-200ms response time
Complex Reasoning: 200-1000ms with self-refinement
Memory Usage: ~25MB base + ~1MB per concurrent request
Concurrent Support: Multiple simultaneous reasoning requests
Troubleshooting
Common Issues
"No module named 'pydantic'" or similar
Install dependencies:
pip install -r requirements.txt
"Clingo not available"
Install Clingo:
pip install clingo
Server will run with limited functionality if Clingo is missing
Server fails to start
Check Python version:
python --version
(requires 3.8+)Test installation:
logic-lm-mcp --help
MCP connection issues
Verify MCP server configuration:
claude mcp get logic-lm
Check installation:
logic-lm-mcp --help
Getting Help
Test installation:
logic-lm-mcp --help
Check the health endpoint: use
check_solver_health
toolEnable debug traces: set
include_trace=true
in requests
FAQ - Common Setup Errors
"Missing required dependencies" on startup
Error:
Cause: Dependencies not properly installed or virtual environment not activated.
Solution:
"ModuleNotFoundError: No module named 'fastmcp'"
Error:
Cause: Virtual environment not properly activated or dependencies not installed.
Solution:
"ModuleNotFoundError: No module named 'pydantic'"
Error:
Cause: Missing core dependency, often from incomplete installation.
Solution:
Virtual environment using system Python instead of venv Python
Error: Virtual environment is using the system Python instead of the isolated venv Python.
Symptoms:
Packages installed globally instead of in venv
Permission errors during package installation
which python
shows system path after activationInconsistent behavior between development and production
Causes:
Incorrect virtual environment activation
Shell aliases overriding PATH (alias python, alias python3)
Corrupted virtual environment
PATH configuration issues
Solutions:
Option 1: Verify and fix activation
Option 2: Use explicit venv path (most reliable)
Option 3: Recreate virtual environment
Option 4: Use absolute paths in shell
"Clingo not available" but everything else works
Error:
Cause: Clingo ASP solver not installed.
Solution:
Server starts but MCP tools not available
Error: MCP connection fails or tools not found.
Cause: Server not properly configured in Claude Code.
Solution:
Verify server is running:
python start_server.py
Check Claude Code MCP configuration
Restart Claude Code if needed
Use absolute paths in configuration
Python version compatibility issues
Error:
Cause: Python version < 3.8.
Solution:
Background process conflicts
Error: Server won't start, port already in use.
Cause: Previous server instance still running.
Solution:
File permission errors
Error:
Cause: Insufficient file permissions.
Solution:
Import path issues
Error:
Cause: Python can't find local modules.
Solution:
Cache or old dependency conflicts
Error: Server uses old logic after code changes.
Cause: Python bytecode cache or old dependencies.
Solution:
Memory or resource issues
Error: Server crashes or becomes unresponsive.
Cause: Insufficient system resources.
Solution:
Close other applications to free memory
Use smaller
max_models
parameter in requestsCheck system requirements (25MB base memory)
Monitor server logs for resource warnings
Development
Project Structure
Adding New Templates
Edit
src/logic_lm_mcp/asp_templates.py
Add new template to
_initialize_templates()
methodTest with
logic-lm-mcp --help
and MCP tools
Extending Logic Framework
Edit
src/logic_lm_mcp/logic_framework.py
Add new reasoning methods to
LogicFramework
classUpdate FastMCP tools in
src/logic_lm_mcp/main.py
Resources
ASP Templates
The server provides access to ASP templates via MCP resources:
asp-templates://list
- List all available templatesasp-templates://info/{template_name}
- Get template informationasp-templates://template/{template_name}
- Get template code
Available Templates
universal: Universal quantification (All X are Y)
conditional: Conditional rules (If X then Y)
syllogism: Basic syllogistic reasoning
existential: Existential quantification (Some X are Y)
negation: Negation patterns (No X are Y)
set_membership: Set membership and relationships
transitive: Transitive relationships
License
MIT License - See LICENSE file for details.
Support
For issues, feature requests, or questions about Logic-LM reasoning capabilities, please:
Test installation:
logic-lm-mcp --help
Check the troubleshooting section above
Open an issue in the repository with:
Python version
Operating system
Error messages
Installation method used (pip/uv)
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Provides symbolic reasoning capabilities by converting natural language logical problems into Answer Set Programming (ASP) format and solving them using the Clingo solver. Enables users to perform formal logical reasoning, verify logical arguments, and get step-by-step explanations for complex logical problems.
- Attribution
- š Quick Start
- Overview
- Features
- Tools Provided
- Architecture
- Dependencies
- Installation
- Configuration
- Usage Examples
- Testing
- Error Handling
- Performance
- Troubleshooting
- FAQ - Common Setup Errors
- "Missing required dependencies" on startup
- "ModuleNotFoundError: No module named 'fastmcp'"
- "ModuleNotFoundError: No module named 'pydantic'"
- Virtual environment using system Python instead of venv Python
- "Clingo not available" but everything else works
- Server starts but MCP tools not available
- Python version compatibility issues
- Background process conflicts
- File permission errors
- Import path issues
- Cache or old dependency conflicts
- Memory or resource issues
- Development
- Resources
- License
- Support
Related MCP Servers
- -securityAlicense-qualityMCP-Logic is a server that provides AI systems with automated reasoning capabilities, enabling logical theorem proving and model verification using Prover9/Mace4 through a clean MCP interface.Last updated -34MIT License
- AsecurityFlicenseAqualityProvides reasoning content to MCP-enabled AI clients by interfacing with Deepseek's API or a local Ollama server, enabling focused reasoning and thought process visualization.Last updated -13164
- AsecurityAlicenseAqualityA fully featured coding agent that uses symbolic operations (enabled by language servers) and works well even in large code bases. Essentially a free to use alternative to Cursor and Windsurf Agents, Cline, Roo Code and others.Last updated -2514,147MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to autonomously perform symbolic mathematics and computer algebra through SymPy's functionality for manipulating mathematical expressions and equations.Last updated -3240Apache 2.0