MCP server exposing Z3 solver API
Project description
mcp-z3-prover
MCP server exposing Z3 solver API
Install
pip install mcp-z3-prover
Usage
from mcp_z3_prover import mcp
# Run the server
mcp.run()
Or from command line:
mcp-z3-prover
MCP 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 = 4295229443
Development
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_z3_prover-0.1.0.tar.gz.
File metadata
- Download URL: mcp_z3_prover-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f4e03aabede6a38b351eea2880c292d381b6c19a3aa39ea7785b4dd5d702740
|
|
| MD5 |
1abde6045dfa72f9b1d5ef545567dfe6
|
|
| BLAKE2b-256 |
56ce132a050555710ac923cebfac752b2db74fd210c5ced900e98b27250e37f2
|
Provenance
The following attestation bundles were made for mcp_z3_prover-0.1.0.tar.gz:
Publisher:
pypi-publish.yml on daedalus/mcp-z3-prover
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_z3_prover-0.1.0.tar.gz -
Subject digest:
0f4e03aabede6a38b351eea2880c292d381b6c19a3aa39ea7785b4dd5d702740 - Sigstore transparency entry: 1191399250
- Sigstore integration time:
-
Permalink:
daedalus/mcp-z3-prover@b2225fcaa5e2b147e56dcc6b61defde0de3cdbb3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@b2225fcaa5e2b147e56dcc6b61defde0de3cdbb3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_z3_prover-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_z3_prover-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d0d95b7a2b26529ab9ae7f82fc55ccb013578b2a837642bce4caa432ec2ddd6
|
|
| MD5 |
c8fafdd0314e3592b062d073f537c595
|
|
| BLAKE2b-256 |
0395acabc4e708d4ac9bf29aca35babd5b10dd8aee045c4e18d6e42c91797450
|
Provenance
The following attestation bundles were made for mcp_z3_prover-0.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on daedalus/mcp-z3-prover
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_z3_prover-0.1.0-py3-none-any.whl -
Subject digest:
6d0d95b7a2b26529ab9ae7f82fc55ccb013578b2a837642bce4caa432ec2ddd6 - Sigstore transparency entry: 1191399252
- Sigstore integration time:
-
Permalink:
daedalus/mcp-z3-prover@b2225fcaa5e2b147e56dcc6b61defde0de3cdbb3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@b2225fcaa5e2b147e56dcc6b61defde0de3cdbb3 -
Trigger Event:
release
-
Statement type: