Skip to main content
Glama
watamoo

Crossword MCP Server

by watamoo

render_solution

Renders crossword puzzle solutions by applying answer assignments to the grid and returning formatted results after verifying consistency checks.

Instructions

全カギの解答を盤面へ反映し、整合性チェックを通過した描画結果を返す。

Args: assignments (dict[str, str]): clue_id をキーとした解答文字列の辞書。setup 済みのすべてのカギに対して、黒マス以外のセルを埋める語を指定する。 各文字列は純粋なひらがなのみで構成されている必要がある。

Returns: str: 列・行番号付きで整形したグリッド文字列。交差が一致している場合のみ 返される。

Raises: RuntimeError: setup が未実行の場合。 ValueError: 未指定または未知の clue_id がある、解答が空文字、長さ不一致、 ひらがな以外の文字が含まれている、あるいは黒マスとの衝突・既存文字との 矛盾が発生した場合。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assignmentsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'render_solution' tool. It validates the provided assignments for all clues, fills the grid while checking for conflicts with black cells and intersections, and returns a formatted string of the solved grid with full-width row and column numbers.
    @mcp.tool()
    async def render_solution(assignments: dict[str, str]) -> str:
        """全カギの解答を盤面へ反映し、整合性チェックを通過した描画結果を返す。
    
        Args:
            assignments (dict[str, str]): `clue_id` をキーとした解答文字列の辞書。`setup`
                済みのすべてのカギに対して、黒マス以外のセルを埋める語を指定する。
                各文字列は純粋なひらがなのみで構成されている必要がある。
    
        Returns:
            str: 列・行番号付きで整形したグリッド文字列。交差が一致している場合のみ
                返される。
    
        Raises:
            RuntimeError: `setup` が未実行の場合。
            ValueError: 未指定または未知の `clue_id` がある、解答が空文字、長さ不一致、
                ひらがな以外の文字が含まれている、あるいは黒マスとの衝突・既存文字との
                矛盾が発生した場合。
        """
    
        _ensure_setup()
    
        if not assignments:
            raise ValueError("assignments が空です。全てのカギに対する解答を指定してください。")
    
        expected_ids = set(state.clues.keys())
        provided_ids = set(assignments.keys())
    
        missing = expected_ids - provided_ids
        extra = provided_ids - expected_ids
    
        if missing:
            raise ValueError(f"未指定の clue_id があります: {sorted(missing)}")
        if extra:
            raise ValueError(f"未知の clue_id が含まれています: {sorted(extra)}")
    
        grid = [row[:] for row in state.grid]
    
        for clue_id, answer in assignments.items():
            clue = state.clues[clue_id]
            word = answer.strip()
            if not word:
                raise ValueError(f"clue_id={clue_id} の解答が空文字です。")
            if len(word) != clue.length:
                raise ValueError(f"clue_id={clue_id} の長さが一致しません: {len(word)} ≠ {clue.length}")
    
            for char in word:
                code = ord(char)
                if not (0x3041 <= code <= 0x309F):
                    raise ValueError(f"clue_id={clue_id} の解答にひらがな以外の文字が含まれています: {char}")
    
            for (row_idx, col_idx), char in zip(clue.positions, word):
                cell = grid[row_idx][col_idx]
                if cell == BLOCK_CELL:
                    raise ValueError(f"clue_id={clue_id} の配置が黒マスと衝突しています。")
                if cell != FILLABLE_CELL and cell != char:
                    raise ValueError(f"位置({row_idx + 1},{col_idx + 1}) で文字が衝突しました: {cell} vs {char}")
                grid[row_idx][col_idx] = char
    
        if not grid:
            return ""
    
        width = len(grid[0])
        header = "  " + " ".join(_to_fullwidth_number(i + 1) for i in range(width))
        lines = [header]
    
        for idx, row in enumerate(grid, start=1):
            lines.append(f"{_to_fullwidth_number(idx)} {' '.join(row)}")
    
        return "\n".join(lines)
Behavior4/5

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

With no annotations provided, the description carries full burden and does so effectively. It discloses critical behavioral traits: it performs validation ('整合性チェックを通過した'), returns only consistent results ('交差が一致している場合のみ返される'), and raises specific errors for various failure modes (RuntimeError, ValueError). This covers safety, validation logic, and error conditions beyond basic input/output.

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 efficiently structured with a clear purpose statement, followed by organized sections for Args, Returns, and Raises. Each sentence adds value: the first defines the core action, and subsequent sections provide essential usage details without redundancy. It's appropriately sized for a tool with complex validation logic.

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?

Given the tool's complexity (validation, rendering, error handling), no annotations, and an output schema present, the description is complete. It covers purpose, prerequisites, parameter semantics, return format, and error conditions thoroughly. The output schema handles return structure, so the description appropriately focuses on behavioral context and constraints.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully. It does so by explaining the parameter's purpose ('clue_id をキーとした解答文字列の辞書'), constraints ('setup 済みのすべてのカギに対して', '黒マス以外のセルを埋める語'), format requirements ('純粋なひらがなのみで構成されている必要がある'), and error cases related to it. This adds substantial meaning beyond the bare schema.

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 the specific action ('render_solution', '反映し', '返す') and resource ('盤面', '描画結果') with explicit scope ('全カギの解答', '整合性チェックを通過した'). It distinguishes from siblings like 'get_candidates' (retrieval) or 'setup' (initialization) by focusing on rendering validated solutions.

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 implies usage context by mentioning prerequisites ('setup 済みのすべてのカギに対して') and errors ('setup が未実行の場合'), and distinguishes from siblings by its focus on rendering validated assignments rather than searching or registering candidates. However, it lacks explicit when-not-to-use guidance or named alternatives for overlapping functions.

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/watamoo/mcp-crossword-tools'

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