Z3/SMT MCP Server
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., "@Z3/SMT MCP Server solve x + y = 10, x - y = 4 for integers"
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.
Z3/SMT MCP Server
An MCP (Model Context Protocol) server that exposes Z3/SMT solver capabilities for constraint solving, logical reasoning, and satisfiability checking.
Features
Direct Z3 Python code execution - Run arbitrary Z3 Python code
SMT-LIB 2.0 support - Parse and solve SMT-LIB format problems
Constraint checking - Check satisfiability of constraint lists
Theorem proving - Prove theorems by showing unsatisfiability of negation
Expression simplification - Simplify Z3 expressions
Logic program solving - Parse and solve structured logic programs (Logic-LLM format)
Session management - Incremental solving with push/pop support
Related MCP server: MCP Optimizer
Installation
# Using pip
pip install z3smt-mcp
# Or install from source
git clone https://github.com/z3smt-mcp/z3smt-mcp
cd z3smt-mcp
pip install -e .Requirements
Python >= 3.10
z3-solver >= 4.12.0
mcp >= 1.0.0
Usage
Running the Server
# Run directly
z3smt-mcp
# Or via Python
python -m z3smt_mcp.serverClaude Desktop Configuration
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"z3smt": {
"command": "z3smt-mcp"
}
}
}Or if installed from source:
{
"mcpServers": {
"z3smt": {
"command": "python",
"args": ["-m", "z3smt_mcp.server"]
}
}
}Available Tools
solve
Execute Z3 Python code directly. All Z3 imports are pre-loaded.
# Example: Solve a system of linear equations
x = Int('x')
y = Int('y')
solver = Solver()
solver.add(x + y == 10)
solver.add(x - y == 4)
if solver.check() == sat:
print(solver.model())
# Output: [y = 3, x = 7]solve_smtlib
Solve problems in SMT-LIB 2.0 format.
(declare-const x Int)
(declare-const y Int)
(assert (= (+ x y) 10))
(assert (= (- x y) 4))
(check-sat)
(get-model)check_sat
Check satisfiability of a list of constraints with automatic variable detection.
{
"constraints": ["x + y == 10", "x > 0", "y > 0", "x < y"]
}prove
Prove a theorem by showing its negation is unsatisfiable.
{
"theorem": "Implies(And(x > 0, y > 0), x + y > 0)",
"variables": {"x": "int", "y": "int"}
}simplify
Simplify a Z3 expression.
{
"expression": "And(x > 0, Or(x > 0, y > 0))"
}solve_logic_program
Solve structured logic programs in Logic-LLM format.
# Declarations
Color = EnumSort([red, green, blue])
assign = Function(Object -> Color)
# Constraints
assign(obj1) != assign(obj2)
Distinct([c:Color], assign(c))Session Management Tools
session_add_variable- Add a variable to the sessionsession_add_constraint- Add a constraint to the sessionsession_check- Check satisfiability and get modelsession_push- Push a new context (for backtracking)session_pop- Pop context (backtrack)session_reset- Clear the sessionlist_sessions- List all active sessions
Examples
Solving Sudoku
# Create a 9x9 grid of integer variables
X = [[Int(f"x_{i}_{j}") for j in range(9)] for i in range(9)]
solver = Solver()
# Each cell contains a value in 1-9
for i in range(9):
for j in range(9):
solver.add(And(X[i][j] >= 1, X[i][j] <= 9))
# Each row has distinct values
for i in range(9):
solver.add(Distinct(X[i]))
# Each column has distinct values
for j in range(9):
solver.add(Distinct([X[i][j] for i in range(9)]))
# Each 3x3 box has distinct values
for box_i in range(3):
for box_j in range(3):
box = [X[3*box_i + i][3*box_j + j]
for i in range(3) for j in range(3)]
solver.add(Distinct(box))
# Add known values (example)
solver.add(X[0][0] == 5)
solver.add(X[0][1] == 3)
# ... more constraints
if solver.check() == sat:
m = solver.model()
for i in range(9):
print([m[X[i][j]] for j in range(9)])Bit-Vector Arithmetic
# Solve for x where x * 3 == 21 in 8-bit arithmetic
x = BitVec('x', 8)
solver = Solver()
solver.add(x * 3 == 21)
if solver.check() == sat:
print(solver.model())Array Theory
# Find an array where a[0] + a[1] == 10
a = Array('a', IntSort(), IntSort())
solver = Solver()
solver.add(a[0] + a[1] == 10)
solver.add(a[0] > 0)
solver.add(a[1] > 0)
if solver.check() == sat:
print(solver.model())Credits
Z3 solver implementation adapted from Logic-LLM
MCP interface inspired by clingo-mcp
Z3 Theorem Prover by Microsoft Research
License
MIT License
Available Tools
13 toolscheck_satA
Check satisfiability of a list of constraints.
Provide constraints as Z3 Python expressions. Variables will be auto-declared based on usage.
Example constraints:
"x + y == 10"
"x > 0"
"And(x < 100, y < 100)"
Inputs: constraints (required), variables, timeout_ms.
list_sessionsA
List all active solver sessions.
Inputs: no named parameters.
proveA
Attempt to prove a theorem by showing its negation is unsatisfiable.
Provide the theorem as a Z3 expression. If the negation is unsatisfiable, the theorem is proven.
Example: prove "ForAll([x], x + 0 == x)" for integer x
Inputs: theorem (required), variables, timeout_ms.
session_add_constraintA
Add a constraint to the current solver session.
The constraint should be a valid Z3 expression using previously declared variables.
Inputs: constraint (required), session_id.
session_add_variableB
Add a variable to the current solver session.
Supported types: int, real, bool, bitvec (with bits parameter)
Inputs: name (required), var_type (required), session_id, bits.
session_checkB
Check satisfiability of current session constraints and get the model if satisfiable.
Inputs: session_id.
session_popB
Pop a context from the solver stack (backtrack).
Inputs: session_id.
session_pushA
Push a new context onto the solver stack (for backtracking).
Inputs: session_id.
session_resetA
Reset the current solver session, clearing all variables and constraints.
Inputs: session_id.
simplifyA
Simplify a Z3 expression.
Returns the simplified form of the given expression.
Example: simplify "And(x > 0, x > 0)" -> "x > 0"
Inputs: expression (required), variables.
solveB
Execute Z3 Python code to solve SMT constraints.
The code can use any Z3 Python API functions. Common imports (Solver, Int, Real, Bool, And, Or, Not, etc.) are pre-loaded.
Example:
x = Int('x')
y = Int('y')
solver = Solver()
solver.add(x + y == 10)
solver.add(x - y == 4)
if solver.check() == sat:
print(solver.model())Inputs: code (required), timeout_ms.
solve_logic_programA
Solve a structured logic program (Logic-LLM format).
The program should have sections:
Declarations
EnumSort, IntSort, Function declarations
Constraints
Logical constraints
Example:
# Declarations
Color = EnumSort([red, green, blue])
assign = Function(Object -> Color)
# Constraints
assign(obj1) != assign(obj2)Inputs: logic_program (required), timeout_ms.
solve_smtlibC
Solve an SMT problem in SMT-LIB 2.0 format.
Example:
(declare-const x Int)
(declare-const y Int)
(assert (= (+ x y) 10))
(assert (= (- x y) 4))
(check-sat)
(get-model)Inputs: smtlib_code (required), timeout_ms.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Most tools have clear distinct purposes, but check_sat, session_check, and solve all involve satisfiability checking and could cause confusion if descriptions are not carefully read. The session_* family is well-grouped.
Uses snake_case consistently, but some tools are single verbs (prove, simplify, solve) while others use noun_verb_noun pattern (session_add_constraint) or verb_noun (check_sat, list_sessions). The session_ prefix provides grouping but introduces inconsistency.
13 tools is appropriate for an SMT solver server, covering constraint solving, session management, multiple input formats, and theorem proving. Not too few or too many.
Covers core SMT operations well: standalone checking, session management, multiple input formats, and simplification. Minor gap: standalone check_sat may not return model, but session_check does. No explicit session deletion, but reset suffices.
Maintenance
Related MCP Connectors
Jailbreak-proof AI guardrails. Automated Reasoning SMT solver, not an LLM. ZK proofs included.
Deterministic reasoning stack for AI agents: simulate, decide & compute, plus cross-domain tools.
Zero-trust logic judge: ZFL claims, algebra derivation steps, sets defined by a property.
Write, type-check and run AILANG in a sandbox, with Z3-proved contracts and docs search.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides 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.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables solving linear programming (LP) and mixed-integer linear programming (MILP) optimization problems through natural language, with built-in simplex and branch-and-cut solvers plus infeasibility diagnostics. Includes optional OR-Tools fallback for larger problems and supports parsing optimization problems from natural language descriptions.MIT
- AlicenseNot gradedqualityDmaintenanceEnables formal logical reasoning, mathematical problem-solving, and proof construction across 11 logic systems including propositional, predicate, modal, fuzzy, and probabilistic logic. Integrates external solvers (Z3, ProbLog, Clingo) for advanced reasoning, with support for proof storage, argument scoring, and cross-system translation.1MIT
- AlicenseNot gradedqualityNot gradedmaintenanceAn MCP server that enables Large Language Models to interactively create, edit, and solve constraint models using backends like MiniZinc, Z3, PySAT, and Clingo. It bridges natural language with symbolic reasoning for solving complex logical, SAT, SMT, and optimization problems.MIT