Get the FREE Ultimate OpenClaw Setup Guide →

prolog

MCP server to allow to connect to a Prolog server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio wendelinism-prolog-mcp-server python -m prolog_mcp_server --transport=stdio

How to use

This MCP server provides an interface for large language models to interact with SWI-Prolog by sending facts, rules (clauses), and queries through the MCP protocol. It enables LLMs to incrementally extend a Prolog knowledge base and perform logical reasoning by issuing Prolog queries and receiving results via either stdio or HTTP transports. The server is designed to be easily integrated into agent workflows and is compatible with MCP Inspector for debugging and interactive testing. Tools exposed by the server allow adding clauses, querying the knowledge base, and leveraging SWI-Prolog’s reasoning capabilities within an MCP-enabled application.

To use it, run the server in your environment (stdio transport is commonly used for in-process LLM integrations). Clients can connect via the MCP protocol to execute Prolog commands, request query results, or upload rules. When using Claude Desktop or similar tooling, you can configure the MCP server as a local service so that the agent can send Prolog code and retrieve results as part of its reasoning loop. The project also provides a demo setup for HTTP transport if you prefer a standalone HTTP endpoint for Prolog interactions.

How to install

Prerequisites:

  • Python 3.8 or higher
  • Git
  • Docker (optional for running the Prolog runtime in containers)

Linux/macOS/Windows installation steps:

  1. Clone the repository
git clone https://github.com/wendelinism/prolog-mcp-server.git
  1. Move into the project directory
cd prolog-mcp-server/
  1. Create and activate a Python virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate  # on Unix/macOS
.venv\Scripts\activate     # on Windows
  1. Install the Python package and dependencies in editable mode
pip install -e .
  1. Build the Docker image for the embedded Prolog runtime (optional but recommended for isolation)
docker buildx build -t prolog-docker-image -f docker/prolog.dockerfile .
  1. If you want to run via Docker, ensure you have permission to access Docker (add yourself to the docker group if needed and restart your session)
sudo usermod -aG docker $USER
exec su - $USER

Windows/Mac notes:

  • The same steps apply; ensure Python is available and that Docker (if used) is installed and running.

Additional notes

Environment and configuration tips:

  • The MCP server supports both stdio and HTTP transports. Use stdio for in-process integration with an LLM, and HTTP if you want an external endpoint for clients to connect.
  • When integrating with Claude Desktop or similar tools, you can configure the MCP server as shown in the example Claude config to start the server automatically in the desired environment.
  • If you run the Docker image, ensure the Prolog runtime is built into the image (docker/prolog.dockerfile) so the MCP server can connect to Prolog.
  • Common issues include port conflicts for HTTP transport, missing Python dependencies, or incorrect module paths. Verify you are invoking the correct module name (prolog_mcp_server) when using python -m.
  • For debugging, MCP Inspector can be used to inspect available tools and test command sequences once the server is running.

Related MCP Servers

Sponsor this space

Reach thousands of developers