Skip to main content

Partially-observable twisty puzzle environment as MCP tools

Project description

twisty

A partially-observable twisty puzzle environment exposed as MCP tools.

The cube is fixed in space. From any viewpoint you see exactly 3 of 6 faces — the other 3 are hidden. Rotate the camera to reveal new faces, apply moves to solve, and try to minimize total steps.

Cube net render showing visible and hidden faces

Quick start

Claude Code:

claude mcp add --transport stdio twisty -- uvx twisty

Codex CLI:

codex mcp add twisty -- uvx twisty

Claude Desktop / Cursor / VS Code — add to your MCP config:

{
  "mcpServers": {
    "twisty": {
      "type": "stdio",
      "command": "uvx",
      "args": ["twisty"]
    }
  }
}

Or commit .mcp.json to your repo for team sharing — Claude Code will auto-detect it.

How it works

This is a Partially Observable Markov Decision Process (POMDP). The agent interacts with a standard 3x3 cube through a constrained observation model:

  • Fixed cube — the cube doesn't rotate; R always turns the Right face clockwise
  • 8 viewpoints — 4 top-ring and 4 bottom-ring camera positions, each revealing 3 faces
  • Partial observability — at any moment, 3 faces are visible and 3 are hidden
  • Cost model — face turns cost 1 move step, camera rotations cost 1 inspection step
  • Goal — solve the cube while minimizing total steps (moves + inspections)

A typical session: scramble()look() → plan → move() / rotate_view() → repeat until is_solved() returns true.

Tools

Tool Description Cost
scramble(num_moves) Scramble with n random moves (default 20)
look() Read the current 3-face view Free
rotate_view(direction) Orbit camera: left, right, up, down 1 inspection
move(notation) Apply a face turn: R, U', F2, L, D', B2, etc. 1 move
is_solved() Check if the cube is solved Free
get_history() Moves applied since last scramble Free
get_stats() Moves, inspections, total steps, solved status Free
reset() Reset to solved state

What the model sees

Each tool call returns a net render of the cube — visible faces in color, hidden faces hatched out:

Front-Right-Top Front-Left-Top Front-Right-Bottom
FRT viewpoint FLT viewpoint FRB viewpoint
Sees F, R, U Sees F, L, U Sees F, R, D

Live viewer

A browser-based 3D viewer launches automatically at localhost:4321 when the server starts. It shows:

  • Animated cube state via cubing.js TwistyPlayer
  • Camera synced to the agent's current viewpoint
  • Viewpoint net highlighting visible faces
  • Move and inspection counters
  • Tool call history
  • Picture-in-Picture mode for watching while the agent works in another window

Development

git clone https://github.com/tejadhith/cube.git
cd cube
uv sync
uv run cube-server

Built with

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twisty-0.1.2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twisty-0.1.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file twisty-0.1.2.tar.gz.

File metadata

  • Download URL: twisty-0.1.2.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for twisty-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4cb14ad68cfbfc021b94e081e81742fa67c4918c25ab8329801087a4620f7a05
MD5 6a9b94b166b754bce584f6cfc57bee57
BLAKE2b-256 90dd1a1f06b7788afcabd72b4a36a2171ea62f1421a2fc7cba94ff986b790063

See more details on using hashes here.

File details

Details for the file twisty-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: twisty-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for twisty-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eecc3fef4421406123e734f798eb24c8ab6779b8348e568197433b5ed2b62ed3
MD5 acce60d45d5793219f4e2c6a0586b9ec
BLAKE2b-256 e5a21779f9333031042bae86034f3b6ff58d35d74ca77c02502ed048defeb5c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page