Skip to main content
Glama
watamoo
by watamoo

register_candidates

Add candidate words to crossword clues that match the required character length. Returns registered words and rejected mismatches for solving Japanese crosswords.

Instructions

指定したカギに対して文字数がマッチする候補語を追加登録する。登録済みと除外された語をまとめて返す。

Args: clue_id (str): 登録対象のカギ ID。setup で読み込んだカギ定義に存在している 必要がある。前後の空白は自動で除去される。 candidates (list[str]): 追加したい候補語のリスト。空文字は許容されない。 カギの length と文字数が一致しない語は登録されず、除外リストに入る。

Returns: dict[str, list[str]]: registered に登録後の候補語リスト(過去の登録分を含む)、 rejected に長さ不一致で追加できなかった語のリストを格納する辞書。

Notes: 長さが一致した語のみ状態に追加され、既存の候補リストは保持したまま追記される。 同じ語が既に登録済みの場合は無視される。

Raises: RuntimeError: setup をまだ呼び出していない場合。 ValueError: clue_id が空、または候補語が空文字だった場合。 KeyError: 指定した clue_id のカギが存在しない場合。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
candidatesYes
clue_idYes

Implementation Reference

  • The core handler function for the 'register_candidates' tool. It is registered via the @mcp.tool() decorator. The function ensures the puzzle is set up, validates the clue_id, filters and adds unique length-matching candidates to the state, ignoring duplicates, and returns lists of registered and rejected candidates. The docstring provides the input/output schema description.
    @mcp.tool() async def register_candidates( clue_id: str, candidates: list[str], ) -> dict[str, list[str]]: """指定したカギに対して文字数がマッチする候補語を追加登録する。登録済みと除外された語をまとめて返す。 Args: clue_id (str): 登録対象のカギ ID。`setup` で読み込んだカギ定義に存在している 必要がある。前後の空白は自動で除去される。 candidates (list[str]): 追加したい候補語のリスト。空文字は許容されない。 カギの `length` と文字数が一致しない語は登録されず、除外リストに入る。 Returns: dict[str, list[str]]: `registered` に登録後の候補語リスト(過去の登録分を含む)、 `rejected` に長さ不一致で追加できなかった語のリストを格納する辞書。 Notes: 長さが一致した語のみ状態に追加され、既存の候補リストは保持したまま追記される。 同じ語が既に登録済みの場合は無視される。 Raises: RuntimeError: `setup` をまだ呼び出していない場合。 ValueError: `clue_id` が空、または候補語が空文字だった場合。 KeyError: 指定した `clue_id` のカギが存在しない場合。 """ _ensure_setup() if not clue_id: raise ValueError("clue_id は必須です。") clue_id = clue_id.strip() if clue_id not in state.clues: raise KeyError("指定された clue_id のカギが存在しません。") clue = state.clues[clue_id] existing = state.candidates.get(clue_id) if existing is None: existing = [] rejected: list[str] = [] for candidate in candidates: word = candidate.strip() if not word: raise ValueError("空の候補は登録できません。") if len(word) == clue.length: if word not in existing: existing.append(word) else: rejected.append(word) state.candidates[clue_id] = existing final_registered = state.candidates.get(clue_id, []) return {"登録済みの候補語リスト": list(final_registered), "文字数がマッチせず登録されなかった候補語リスト": rejected}

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