Z3 Theorem Prover with Functional Programming

by javergar

5 stars
314 downloads
Not rated
GitHub

About

A Python MCP server that wraps the Z3 Theorem Prover using functional programming principles—immutable data structures, monadic error handling, and pure functions—to solve constraint satisfaction problems and analyze entity relationships.

Details

Author
javergar
GitHub stars
5
Downloads
314
Categories
Other

- Constraint satisfaction problem solving with Z3
- Relationship analysis and inference between entities
- Functional programming: immutable Pydantic models, Result/Maybe types
- MCP server with four tools for constraint and relationship queries
- Simple and full-model interfaces for both solvers and analyzers

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Z3 Theorem Prover with Functional Programming
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Clone the repo, install dependencies via uv pip install -e ., then run examples with python -m z3_poc.examples.main or start the MCP server with python -m z3_poc.server.main. Configure the server in your VSCode settings.json under mcpServers to enable it in Claude via Cline.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "z3 theorem prover with functional programming": {
            "z3_mcp": {
                "command": "uv",
                "args": [
                    "pip",
                    "install",
                    "-e",
                    "."
                ]
            }
        }
    }
}

McpServers

{
    "z3_mcp": {
        "command": "uv",
        "args": [
            "pip",
            "install",
            "-e",
            "."
        ]
    }
}

Z3 Theorem Prover with Functional Programming

A Python implementation of abstactions over the Z3 Theorem Prover capabilities using functional programming principles, exposed through a Model Context Protocol (MCP) server.

Overview

This project demonstrates how to use the Z3 Theorem Prover with a functional programming approach to solve complex constraint satisfaction problems and analyze relationships between entities. It leverages the returns library for functional programming abstractions and exposes its capabilities through an MCP server.

Features

- Constraint Satisfaction Problems: Solve complex problems with variables and constraints
- Relationship Analysis: Analyze and infer relationships between entities
- Functional Programming: Uses pure functions, immutable data structures, and monadic error handling
- MCP Server: Exposes Z3 capabilities through a standardized interface

Project Structure

z3_mcp/
├── core/                  # Core implementation
│   ├── solver.py          # Constraint satisfaction problem solving
│   └── relationships.py   # Relationship analysis
├── models/                # Data models
│   ├── constraints.py     # Models for constraint problems
│   └── relationships.py   # Models for relationship analysis
├── server/                # MCP server
│   └── main.py            # Server implementation
└── examples/              # Example usage
    └── main.py            # Demonstration of capabilities

Technical Stack

- Z3 Solver: Microsoft's theorem prover for constraint solving
- Returns: Functional programming library for monadic operations and error handling
- Pydantic: Data validation and serialization
- FastMCP: Implementation of the Model Context Protocol

Installation

This project uses uv for dependency management.

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.