Skip to main content

Python 3.13+ pytest PyPI GitHub commits since latest release CodeQL Advanced OpenSSF Scorecard License: MIT

╭─╮╭┬╮╶┬╴   ╭─╮╷ ╷╶┬╮╭─╮╷╭ ╷ ╷
╰─╮│││ │    ╰─╮│ │ │││ │├┴╮│ │
╰─╯╵ ╵ ╵    ╰─╯╰─╯╶┴╯╰─╯╵ ╵╰─╯

smt-sudoku-mcp

Now, your agents can play Sudoku confidently!

An MCP server that demonstrates the power of satisfiability modulo theories (SMT) solving, using Z3, through the classic constraint-satisfaction puzzle of Sudoku.

Sudoku maps cleanly onto SMT primitives: generating a puzzle means finding a model that satisfies the Sudoku constraints and then proving a reduced set of clues still has only one solution; validating a grid means checking those same constraints against given cell values; solving a puzzle means finding a model or proving none exists.

Tools

All four tools are stateless: every call takes and/or returns a complete grid explicitly, with no server-side session state.

A Sudoku grid is represented as {"rows": [[...9 ints...], ...9 rows...]}, where each cell is 1-9 for a given digit or 0 for an empty cell. Any tool result that names a specific cell (a conflict) reports row/col as 1-indexed, matching how Sudoku cells are conventionally described in text (row 1, column 1 is the top-left cell).

generate_sudoku_puzzle

Generates a new, uniquely-solvable Sudoku puzzle.

  • Input: difficulty — one of "very easy", "easy", "medium", "hard", or "very hard" (default "medium"), mapping to an approximate target clue count.
  • Output: {"puzzle": <grid>, "difficulty": <str>, "givens": <int>}givens is the actual number of filled cells, which may be slightly above the target if removing further cells would have broken uniqueness.

validate_partial_sudoku_solution

Checks whether a partially-filled grid is conflict-free and, if so, whether it can still be completed.

  • Input: grid — a partial grid (0 for empty cells).
  • Output: {"conflicts": [<cell>, ...], "is_completable": <bool | null>, "empty_cells": [<cell>, ...], "has_conflicts": <bool>, "empty_cells_count": <int>}is_completable is null when conflicts are present, since completability is not a meaningful question until they are resolved. empty_cells lists every still-empty cell regardless of has_conflicts; empty_cells_count is len(empty_cells).

validate_full_sudoku_solution

Checks whether a fully-filled grid is a correct Sudoku solution.

  • Input: grid — expected to have no empty cells.
  • Output: {"has_empty_cells": <bool>, "conflicts": [<cell>, ...], "is_valid": <bool>}.

solve_sudoku_puzzle

Solves an unsolved grid, or reports why it cannot be solved.

  • Input: grid — a partial grid to solve (0 for empty cells).
  • Output: {"status": "satisfiable" | "conflicting_givens" | "unsatisfiable", "solution": <grid | null>, "conflicts": [<cell>, ...]}. conflicts is only populated when status is "conflicting_givens" (two given cells directly violate a row/column/box rule); "unsatisfiable" means the givens are pairwise conflict-free but no completion exists.

Installation

Requires Python 3.13+. The package is published on PyPI.

The simplest way to run it is with uvx, which fetches the package into an ephemeral environment on first use and requires no separate install step:

uvx smt-sudoku-mcp

Alternatively, install it with pip (or uv pip) and run the installed console script directly:

pip install smt-sudoku-mcp
smt-sudoku-mcp

To work on the source itself rather than the published package, see Development below.

Using it with an MCP client

This server speaks MCP over stdio by default, so any MCP client that can launch a subprocess can use it without further setup. Set SMT_SUDOKU_MCP_TRANSPORT=streamable-http instead if the client needs to reach a standalone HTTP service; see Configuration.

Claude Code

claude mcp add smt-sudoku -- uvx smt-sudoku-mcp

Claude Desktop

Add an entry under Settings → Developer → Edit Config (claude_desktop_config.json):

{
  "mcpServers": {
    "smt-sudoku": {
      "command": "uvx",
      "args": ["smt-sudoku-mcp"]
    }
  }
}

Other MCP clients and agent frameworks

Any client that accepts a raw MCP server definition — Cursor, Windsurf, VS Code, or a custom agent built on an MCP SDK — can use the same command/args pair: uvx and ["smt-sudoku-mcp"]. For streamable-http, run the server separately with SMT_SUDOKU_MCP_TRANSPORT=streamable-http uvx smt-sudoku-mcp and point the client at http://<host>:<port>/mcp rather than giving it a command to launch.

Once connected, an agent can call the four tools above as it would any other tool. For example, asking an agent to "generate a hard Sudoku puzzle, then solve it and check the solution" will chain generate_sudoku_puzzle, solve_sudoku_puzzle, and validate_full_sudoku_solution without further guidance, since each tool's description and schema are sufficient for the agent to plan the sequence itself.

Configuration

Environment variables, all optional:

Variable Default Description
SMT_SUDOKU_MCP_TRANSPORT stdio stdio or streamable-http
SMT_SUDOKU_MCP_HOST 127.0.0.1 Bind host, streamable-http only
SMT_SUDOKU_MCP_PORT 8000 Bind port, streamable-http only
SMT_SUDOKU_MCP_ALLOWED_ORIGINS (none) Comma-separated browser origins to trust, streamable-http only

Development

To run the server from a source checkout instead of the published package, use uv:

uv sync
uv run smt-sudoku-mcp

See AGENTS.md for architecture notes and the full set of development commands (just -l).

Contributing

Issues and pull requests are welcome.

License

MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smt_sudoku_mcp-0.2.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smt_sudoku_mcp-0.2.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file smt_sudoku_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: smt_sudoku_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for smt_sudoku_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7b95ef2e98cebd64b5e99d6c341c294b74466b2a1341af5c5cac52e6abe5dc7e
MD5 016a94363cd9dc2d641bd4f934d9e782
BLAKE2b-256 ebe877067b7c3f1b974ec0d4328d326eb65e1c11788f943625df6e350f69bc54

See more details on using hashes here.

File details

Details for the file smt_sudoku_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: smt_sudoku_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for smt_sudoku_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db8212ed1b94cc64b12e170c7e75d14f5d96b3ace475b9ed0d4cb1bfc88568a0
MD5 7b931d8fbfe2d11a7fe22163d083c03e
BLAKE2b-256 45cb68639e573b989062b35d0b342deef9c85e89d7385fd63db2053e2e5e9f36

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0.post1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page