Skip to main content
Glama

Crossword MCP Server

by watamoo
test.py2.88 kB
import asyncio import server def expect_error(label: str, coro, expected_exc: type[BaseException]) -> None: "ラベル付きで例外送出を検証する簡易ヘルパー" try: asyncio.run(coro) except expected_exc as exc: # type: ignore[misc] print(f"[OK] {label}: {expected_exc.__name__} -> {exc}") return except Exception as exc: # noqa: BLE001 raise AssertionError(f"{label}: {expected_exc.__name__} を期待したが {type(exc).__name__} が発生") from exc raise AssertionError(f"{label}: 期待した {expected_exc.__name__} が発生しませんでした") def main() -> None: grid_text = """ 1 2 3 1 ? ? ? 2 ? # ? 3 ? ? ? """ clue_text = """ {"id": "1", "direction": "down", "row": 1, "col": 1, "length": 3, "clue": "2つのことをくらべること"} {"id": "2", "direction": "down", "row": 1, "col": 3, "length": 3, "clue": "山や森にすむ動物。人を化かすといわれる"} {"id": "3", "direction": "across", "row": 1, "col": 1, "length": 3, "clue": "日本の昔話に出てくる動物。葉っぱを頭にのせて化ける"} {"id": "4", "direction": "across", "row": 3, "col": 1, "length": 3, "clue": "昼ごはんを食べた後にしたくなる"} """ print("=== Test setup ===") grid = asyncio.run(server.setup.fn(grid_text, clue_text)) print(grid) print("=== Error cases ===") expect_error("search before register", server.search_consistent_sets.fn(), RuntimeError) expect_error("register invalid id", server.register_candidates.fn("0", ["あいす", "あいず"]), KeyError) expect_error("delete invalid id", server.delete_candidates.fn("0", ["dummy"]), KeyError) expect_error("get invalid id", server.get_candidates.fn("0"), KeyError) print("=== Register candidates ===") asyncio.run(server.register_candidates.fn("1", ["たいひ", "ひかく"])) asyncio.run(server.register_candidates.fn("2", ["きつね", "たぬき"])) asyncio.run(server.register_candidates.fn("3", ["かっぱ", "たぬき"])) asyncio.run(server.register_candidates.fn("4", ["ひるな", "あくび"])) deletion = asyncio.run(server.delete_candidates.fn("4", ["ひるな", "存在しない"])) print(deletion) c4_after = asyncio.run(server.get_candidates.fn("4")) print("4:", c4_after) r1 = asyncio.run(server.register_candidates.fn("1", ["みかん", "もも"])) print(r1) print("=== get_candidates ===") c1 = asyncio.run(server.get_candidates.fn("1")) c2 = asyncio.run(server.get_candidates.fn("2")) print("1:", c1) print("2:", c2) print("=== search_consistent_sets ===") solutions = asyncio.run(server.search_consistent_sets.fn()) print("solutions:", solutions) if __name__ == "__main__": main()

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