Skip to main content
Glama
Skywalker-Harrison

Soduku Solver MCP Server

add-sudoku

Add a new Sudoku puzzle to the solver's storage by providing a name and puzzle text. This tool enables puzzle submission for solving and analysis.

Instructions

Add a new Sudoku puzzle

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
puzzleYesThe Sudoku puzzle in text format

Implementation Reference

  • Executes the 'add-sudoku' tool: extracts name and puzzle text from arguments, parses the puzzle using parse_sudoku_text, stores in sudoku_puzzles dict, notifies resource changes, formats and returns the grid.
    elif name == "add-sudoku":
        puzzle_name = arguments.get("name")
        puzzle_text = arguments.get("puzzle")
    
        if not puzzle_name or not puzzle_text:
            raise ValueError("Missing name or puzzle")
    
        try:
            # Parse the puzzle
            grid = parse_sudoku_text(puzzle_text)
            
            # Store the puzzle
            sudoku_puzzles[puzzle_name] = grid
            
            # Notify clients that resources have changed
            await server.request_context.session.send_resource_list_changed()
            
            # Return formatted grid
            formatted_grid = format_sudoku_grid(grid)
            
            return [
                types.TextContent(
                    type="text",
                    text=f"Added Sudoku puzzle '{puzzle_name}':\n\n{formatted_grid}",
                )
            ]
        except ValueError as e:
            return [
                types.TextContent(
                    type="text",
                    text=f"Error parsing Sudoku puzzle: {str(e)}",
                )
            ]
  • Registers the 'add-sudoku' tool in handle_list_tools(), providing name, description, and JSON schema for input validation (name and puzzle required).
    types.Tool(
        name="add-sudoku",
        description="Add a new Sudoku puzzle",
        inputSchema={
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "puzzle": {"type": "string", "description": "The Sudoku puzzle in text format"},
            },
            "required": ["name", "puzzle"],
        },
    ),
  • Defines the input schema for 'add-sudoku' tool: object with 'name' (string) and 'puzzle' (string, described).
    inputSchema={
        "type": "object",
        "properties": {
            "name": {"type": "string"},
            "puzzle": {"type": "string", "description": "The Sudoku puzzle in text format"},
        },
        "required": ["name", "puzzle"],
    },
  • Helper function to parse Sudoku puzzle text into a 9x9 grid matrix. Handles various text formats, validates dimensions and values (0-9). Used in add-sudoku handler.
    def parse_sudoku_text(text):
        """
        Parse a Sudoku puzzle from text input.
        
        The input can be in various formats:
        - Space or comma-separated values (0 or . for empty cells)
        - Multiple lines representing rows
        
        Args:
            text: String containing the Sudoku puzzle
            
        Returns:
            list: 9x9 matrix representing the Sudoku puzzle
        """
        # Initialize an empty 9x9 grid
        grid = []
        
        # Split the input into lines
        lines = [line.strip() for line in text.strip().split('\n') if line.strip()]
        
        # If we have a single line, try to parse it as a flat representation
        if len(lines) == 1:
            # Replace common separators with spaces
            flat = lines[0].replace(',', ' ').replace(';', ' ')
            # Replace dots with zeros
            flat = flat.replace('.', '0')
            # Split by whitespace and filter out empty strings
            values = [v for v in flat.split() if v]
            
            # Check if we have enough values
            if len(values) != 81:
                raise ValueError(f"Expected 81 values for a 9x9 Sudoku, got {len(values)}")
            
            # Create the 9x9 grid
            for i in range(9):
                row = []
                for j in range(9):
                    cell = values[i * 9 + j]
                    try:
                        row.append(int(cell))
                    except ValueError:
                        raise ValueError(f"Invalid Sudoku value: {cell}")
                grid.append(row)
        else:
            # Parse multiple lines
            for line in lines:
                if not line.strip():
                    continue
                    
                # Replace dots with zeros and remove other common separators
                line = line.replace('.', '0').replace(',', ' ').replace(';', ' ')
                # Split and filter
                values = [v for v in line.split() if v]
                
                row = []
                for cell in values:
                    try:
                        row.append(int(cell))
                    except ValueError:
                        raise ValueError(f"Invalid Sudoku value: {cell}")
                
                if row:
                    grid.append(row)
        
        # Validate the grid dimensions
        if len(grid) != 9:
            raise ValueError(f"Expected 9 rows for Sudoku, got {len(grid)}")
        
        for i, row in enumerate(grid):
            if len(row) != 9:
                raise ValueError(f"Expected 9 columns in row {i}, got {len(row)}")
        
        # Validate the values (0-9 only)
        for i in range(9):
            for j in range(9):
                if not 0 <= grid[i][j] <= 9:
                    raise ValueError(f"Invalid value {grid[i][j]} at position ({i}, {j})")
        
        return grid
  • Helper function to format 9x9 Sudoku grid as a readable string with borders. Used to display the added puzzle in the tool response.
    def format_sudoku_grid(grid):
        """
        Format a Sudoku grid for display.
        
        Args:
            grid: 9x9 Sudoku grid
            
        Returns:
            str: Formatted string representation of the grid
        """
        result = []
        
        horizontal_line = "+-------+-------+-------+"
        
        for i in range(9):
            if i % 3 == 0:
                result.append(horizontal_line)
            
            row = "| "
            for j in range(9):
                row += str(grid[i][j]) + " "
                if (j + 1) % 3 == 0:
                    row += "| "
                    
            result.append(row)
            
        result.append(horizontal_line)
        
        return "\n".join(result) 
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action ('Add') without disclosing behavioral traits. It doesn't mention whether this is a write operation, what permissions are needed, how errors are handled, or what happens on success, leaving critical behavioral aspects unspecified.

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, efficient sentence with zero wasted words, making it easy to parse and front-loaded with the core action. It appropriately sized for a simple tool without over-explaining.

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

Completeness2/5

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

Given no annotations, no output schema, and incomplete schema coverage (50%), the description is inadequate. It doesn't compensate for the lack of structured data by explaining what the tool returns, error conditions, or behavioral context, leaving significant gaps for a mutation tool.

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 description coverage is 50% (only 'puzzle' has a description), and the description adds no parameter details beyond what the schema provides. It implies parameters for name and puzzle but doesn't explain their semantics, formats, or constraints, resulting in minimal added value over the schema.

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

Purpose4/5

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

The description clearly states the action ('Add') and resource ('a new Sudoku puzzle'), making the purpose immediately understandable. It doesn't differentiate from sibling tools like 'add-note' or 'solve-sudoku', but the specific mention of 'Sudoku puzzle' provides adequate clarity for the domain.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'solve-sudoku' or 'add-note'. The description lacks context about prerequisites, such as whether this is for creating puzzles versus solving them, leaving the agent to infer usage from tool names alone.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Skywalker-Harrison/mcp-soduku'

If you have feedback or need assistance with the MCP directory API, please join our Discord server