Skip to main content
Glama
anirbanbasu

smt-sudoku-mcp

by anirbanbasu

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.

As of 1.0.0, the four tools' input/output schemas below are a stable public contract: any breaking change to them will be called out explicitly in CHANGELOG.md and reflected in a major version bump.

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: 63, 51, 42, 30, and 21 respectively. "very hard"'s target of 21 sits just above the proven minimum of 17 givens for any uniquely-solvable Sudoku puzzle, so in practice it commonly lands noticeably above 21 (e.g. mid-20s), since removal stops once no further cell can be cleared without breaking uniqueness.

  • 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.

Related MCP server: Gurddy MCP Server

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

The server has no built-in authentication or authorization of its own: SMT_SUDOKU_MCP_ALLOWED_ORIGINS and the request guard it feeds protect against spoofed browser origins and DNS-rebinding-style attacks, not against an arbitrary network client calling its tools. There is no scope for adding authentication — this server is intended to be run on a local machine or an otherwise trusted network, never exposed directly to an untrusted network.

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; see CONTRIBUTING.md. See CONTRIBUTORS.md for the list of contributors, and CHANGELOG.md for the release history.

Security

See SECURITY.md for the vulnerability disclosure policy.

License

MIT.

Available Tools

4 tools
generate_sudoku_puzzleGenerate Sudoku PuzzleA

Generate a new, uniquely-solvable Sudoku puzzle at the given difficulty.

ParametersJSON Schema
NameRequiredDescriptionDefault
difficultyNomedium

Output Schema

ParametersJSON Schema
NameRequiredDescription
givensYesActual number of filled cells in the generated puzzle
puzzleYesA 9x9 Sudoku grid; 0 marks an empty cell.
difficultyYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the behavioral disclosure burden. It does disclose two important behaviors: the generated puzzle is 'new' (freshly generated) and 'uniquely-solvable' (guaranteed to have a single solution). It does not explain the exact output shape, but the presence of an output schema reduces the need for that detail.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no filler. It front-loads the core action and then adds the essential constraints ('uniquely-solvable', 'at the given difficulty'), making it concise and scannable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-optional-parameter generator with an output schema present, the description is complete enough. It states what is generated, the key quality guarantee, and the input dimension. The solve/validate siblings are clearly outside this tool's scope.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% descriptive coverage, so the description must compensate. It references 'difficulty' and correctly ties it to the generated puzzle's difficulty, but it does not elaborate on the enum values or the default of medium. The self-explanatory enum in the schema does most of the clarifying work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Generate'), a specific resource ('Sudoku puzzle'), and a key qualifier ('uniquely-solvable'). It is clearly distinguished from the sibling tools validate_partial_sudoku_solution, validate_full_sudoku_solution, and solve_sudoku_puzzle because those are validation/solving operations, not generation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is used when a new Sudoku puzzle is needed, but it does not explicitly state when to choose it over the solve/validate siblings or mention any exclusions. Usage context is clear enough from the verb, but alternative-routing guidance is absent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

solve_sudoku_puzzleSolve Sudoku PuzzleA

Solve an unsolved Sudoku grid, or report why it cannot be solved.

ParametersJSON Schema
NameRequiredDescriptionDefault
gridYesA 9x9 Sudoku grid; 0 marks an empty cell.

Output Schema

ParametersJSON Schema
NameRequiredDescription
statusYes
solutionYes
conflictsYesPopulated only when status is conflicting_givens

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses the primary behavior and the failure-reporting behavior, but does not mention side effects, input validity handling, or what happens if the grid is already solved. It is non-contradictory but minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one tight sentence with no wasted words. The primary purpose is front-loaded, and the failure-reporting behavior is appended without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having no annotations, the description adequately defines the tool's contract for a single-parameter operation, and an output schema is available for return-value details. It could be slightly richer on edge cases such as pre-solved or partially invalid grids, but it is largely complete for this tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already documents the grid parameter thoroughly, including 9x9 shape and 0-for-empty semantics, so schema coverage is 100%. The description adds no parameter-specific detail beyond 'unsolved', which is unnecessary because the schema already defines the structure.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific action ('solve') applied to a specific resource ('an unsolved Sudoku grid') and adds a failure-exit behavior ('report why it cannot be solved'). This distinguishes it from the generate and validate siblings based on the core intent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies appropriate use for grids that need solving and for diagnosing unsolvability, but it never explicitly contrasts its use with the sibling validation or generation tools. Usage context is reasonably clear, but exclusions and alternative-tool guidance are left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

validate_full_sudoku_solutionValidate Full Sudoku SolutionA

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

ParametersJSON Schema
NameRequiredDescriptionDefault
gridYesA 9x9 Sudoku grid; 0 marks an empty cell.

Output Schema

ParametersJSON Schema
NameRequiredDescription
is_validYes
conflictsYes
has_empty_cellsYes

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden of behavioral disclosure. It does communicate that this is a read-only validation check, but it does not explain how empty cells (0) are treated, whether standard Sudoku rules are assumed, or what output is returned. The existence of an output schema mitigates the return-shape gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no wasted words, and it front-loads the key constraint ('fully-filled') before the purpose ('correct solution'). This is appropriately concise and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter validator with an output schema, the definition is mostly adequate. However, it does not explicitly state the standard Sudoku rules being validated or clarify how to distinguish this from validate_partial_sudoku_solution, which leaves some ambiguity for an agent deciding between siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already documents the grid parameter thoroughly: 9 rows of 9 cells, digits 1-9, and 0 for empty, giving 100% schema coverage. The description adds the 'fully-filled correct solution' context, but there is a slight tension because the schema explicitly permits empty cells while the description emphasizes a fully-filled grid.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific operation ('Check whether') and a specific resource ('a fully-filled Sudoku grid'), and clarifies the goal is verifying a correct solution. The word 'fully-filled' distinguishes it from the partial-validation sibling, so an agent can select it without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description makes the intended use clear: call it when you have a complete grid and need to know whether it is a valid solution. It does not explicitly name alternative sibling tools or state when not to use it, so it stops short of full routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

validate_partial_sudoku_solutionValidate Partial Sudoku SolutionA

Check whether a partially-filled Sudoku grid is conflict-free and still completable.

ParametersJSON Schema
NameRequiredDescriptionDefault
gridYesA 9x9 Sudoku grid; 0 marks an empty cell.

Output Schema

ParametersJSON Schema
NameRequiredDescription
conflictsYes
empty_cellsYesEvery still-empty cell in the grid, regardless of has_conflicts
has_conflictsYes
is_completableYesWhether the grid can still be completed; None when has_conflicts is True, since completability is not a meaningful question until conflicts are resolved
empty_cells_countYesNumber of still-empty cells, i.e. len(empty_cells)

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the behavioral burden. It discloses the checking criteria (conflict-free, still completable) but does not clarify what 'completable' means (existence of at least one completion vs. uniqueness) or how invalid inputs are handled.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single sentence is concise and front-loaded with the action and key constraints. Every word contributes to understanding what the tool does.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with a rich schema and output schema present, the description is largely complete. The only notable gap is not defining the semantics of 'still completable' or the exact nature of conflict checking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, with the grid and row structures already documented including '0 marks an empty cell.' The description adds only the 'partially-filled' framing, which is useful but not necessary beyond the schema, so the baseline score applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Check whether') and resource ('a partially-filled Sudoku grid'), with explicit criteria: conflict-free and still completable. It clearly distinguishes itself from validate_full_sudoku_solution by focusing on partial grids.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly signals use for partially-filled grids, which differentiates it from validate_full_sudoku_solution and from generation/solving siblings. However, it does not explicitly name alternatives or state when not to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.3.0
    • First observedgenerate_sudoku_puzzle
    • First observedsolve_sudoku_puzzle
    • First observedvalidate_full_sudoku_solution
    • First observedvalidate_partial_sudoku_solution

TDQS

A4.2/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clear, non-overlapping purpose: generating puzzles, validating partial solutions, validating complete solutions, and solving puzzles. There is no ambiguity about which tool to use for a given task.

Naming Consistency5/5

All tool names follow a consistent verb_noun snake_case pattern. The two validation tools share the same verb and differ only by the qualifier 'partial' or 'full', which is intuitive and predictable.

Tool Count5/5

Four tools is a well-scoped set for a Sudoku-specific server. Each tool addresses a distinct core operation without unnecessary bloat or redundancy.

Completeness5/5

The tool surface covers the full Sudoku workflow: puzzle generation, solving, and validation of both in-progress and completed grids. No significant missing operations exist for the stated domain.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP-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 solution
    21
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    2
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    An 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
  • F
    license
    A
    quality
    D
    maintenance
    Enables solving constraint satisfaction problems, mathematical equations, and logic puzzles using the Z3 SMT solver through natural language.
    1
    3
    -