mcp-z3-prover
Click on "Deploy 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-z3-prover Find integer p and q such that p*q = 4295229443 and p,q > 1"
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-z3-prover
MCP server exposing Z3 solver API
Install
pip install mcp-z3-proverRelated MCP server: Google OR-Tools server
Usage
from mcp_z3_prover import mcp
# Run the server
mcp.run()Or from command line:
mcp-z3-proverMCP Tools
The server exposes the following tools:
create_bool_var - Create a Boolean variable
create_int_var - Create an Integer variable
create_real_var - Create a Real variable
create_int_constant - Create an integer constant
create_real_constant - Create a real constant
add_constraint - Add a constraint to the solver
solve - Solve the current problem
get_model_value - Get value of a variable from the model
optimize - Solve with optimization objective
reset_solver - Reset the solver state
list_variables - List all created variables
Example
# Create variables
create_int_var("x")
create_int_var("y")
# Add constraints
add_constraint("int:x + int:y == 10")
add_constraint("int:x > 0")
add_constraint("int:y > 0")
# Solve
result = solve()
# Returns: {"status": "sat", "model": {"x": "5", "y": "5"}}
# Get specific values
x_val = get_model_value("int:x")Integer Factorization Example
# Factor n = 4295229443 where n = p * q with q <= sqrt(n)
create_int_var("p")
create_int_var("q")
# Add constraints
add_constraint("int:p * int:q == 4295229443")
add_constraint("4295229443 > int:p")
add_constraint("4295229443 > int:q")
add_constraint("int:q <= 65537") # sqrt(4295229443) ≈ 65537
add_constraint("int:q > 1")
add_constraint("int:p > 1")
add_constraint("int:q % 2 != 0") # q is odd
add_constraint("int:p % 2 != 0") # p is odd
# Solve
result = solve()
# Returns: {"status": "sat", "model": {"p": "65539", "q": "65537"}}
# Verification: 65537 * 65539 = 4295229443Development
git clone https://github.com/daedalus/mcp-z3-prover.git
cd mcp-z3-prover
pip install -e ".[test]"
# run tests
pytest
# format
ruff format src/ tests/
# lint
ruff check src/ tests/
# type check
mypy src/MCP Registration
mcp-name: io.github.daedalus/mcp-z3-prover
Available Tools
11 toolsadd_constraintA
Add a constraint to the solver.
Use variable references like 'bool:x', 'int:y', 'real:z' in expressions. Supports standard Z3 Python API syntax.
Inputs: constraint (required). Returns: object
create_bool_varB
Create a Boolean variable with the given name.
Inputs: name (required). Returns: result
create_int_constantB
Create an integer constant with the given value.
Inputs: value (required). Returns: result
create_int_varB
Create an Integer variable with the given name.
Inputs: name (required). Returns: result
create_real_constantB
Create a real constant with the given value.
Inputs: value (required). Returns: result
create_real_varB
Create a Real (floating-point) variable with the given name.
Inputs: name (required). Returns: result
get_model_valueA
Get the value of a variable from the model after solving.
Inputs: variable (required). Returns: result
list_variablesA
List all created variables.
Returns: A dictionary containing a list of all variable references.
Example: >>> create_int_var("x") 'int:x' >>> create_bool_var("flag") 'bool:flag' >>> list_variables() {'variables': ['int:x', 'bool:flag']}
Inputs: no named parameters. Returns: object
optimizeA
Solve with an optimization objective (maximize or minimize).
Finds the optimal value for the given objective function subject to all added constraints.
Inputs: objective (required), maximize, timeout_ms. Returns: object
reset_solverA
Reset the solver state.
Clears all variables, constants, constraints, and model data. Useful when starting a new problem.
Returns: A dictionary with status and a success message.
Example: >>> create_int_var("x") 'int:x' >>> add_constraint("int:x > 5") {'status': 'success', 'constraint': 'int:x > 5'} >>> reset_solver() {'status': 'success', 'message': 'Solver reset successfully'} >>> list_variables() {'variables': []}
Inputs: no named parameters. Returns: object
solveB
Solve the current problem and return the result.
Checks all added constraints for satisfiability and returns a model if the problem is SAT.
Inputs: timeout_ms. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool has a clear, distinct purpose: variable creation for different types (bool, int, real) with separate creation of constants and variables, constraint addition, solving, optimization, model retrieval, listing, and reset. No overlap.
All tool names follow a consistent snake_case verb_noun pattern (e.g., create_int_var, add_constraint, get_model_value). No mixing of conventions.
11 tools is well-scoped for a constraint solver. Each tool serves a necessary function without being overly granular or too sparse.
Covers the core workflow: variable creation, constraints, solving, and model retrieval. Minor gaps exist, such as no push/pop for incremental solving or constraint deletion, but the essential operations are present.
Maintenance
Related MCP Connectors
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
MCP server for the Seline Analytics API
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Related MCP Servers
- AlicenseAqualityBmaintenanceA Model Context Protocol (MCP) server that exposes MiniZinc constraint solving capabilities to Large Language Models.6188MIT
- AlicenseNot gradedqualityDmaintenanceMCP-ORTools integrates Google's OR-Tools constraint programming solver with Large Language Models through the MCP, enabling AI models to: Submit and validate constraint models Set model parameters Solve constraint satisfaction and optimization problems Retrieve and analyze solution22MIT
- AlicenseBqualityDmaintenanceMathematical Optimization MCP Server with PuLP and OR-Tools support135MIT
- AlicenseNot gradedqualityDmaintenanceEnables solving Constraint Satisfaction Problems (CSP) like N-Queens, graph coloring, and Sudoku, as well as Linear Programming optimization problems through both MCP tools and HTTP API endpoints.2MIT