Skip to main content
Glama
fritzprix

Rubik's Cube MCP Server

by fritzprix

manipulateCube

Execute standard Rubik's Cube notation moves to manipulate cube positions within game sessions for solving puzzles.

Instructions

Execute a move on the Rubik's Cube

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gameIdYesThe game session ID
moveYesThe cube move to execute

Implementation Reference

  • Handler function that looks up the game session by ID, optionally checks if already completed, executes the cube move, updates session and visualization server, and returns the updated cube state with next action.
    async ({ gameId, move }: { gameId: string; move: string }) => { const game = this.games.get(gameId); if (!game) { throw new Error(`Game session ${gameId} not found`); } const { cube, session } = game; // 이미 해결된 큐브인지 확인 if (session.status === 'completed') { const response: CubeResponse = { gameId, cube: cube.getState(), nextAction: "finish" }; return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } // 움직임 실행 cube.executeMove(move as CubeMove); const newState = cube.getState(); // 세션 업데이트 session.cubeState = newState; session.lastActivity = Date.now(); if (newState.solved) { session.status = 'completed'; } // 시각화 서버 업데이트 this.visualizationServer.updateSession(gameId, newState); const response: CubeResponse = { gameId, cube: newState, nextAction: newState.solved ? "finish" : "manipulateCube" }; return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; }
  • Zod input schema for the manipulateCube tool, validating gameId (string) and move (enum of valid Rubik's Cube moves).
    gameId: z.string().describe("The game session ID"), move: z.enum(['U', 'D', 'L', 'R', 'F', 'B', 'U\'', 'D\'', 'L\'', 'R\'', 'F\'', 'B\'', 'U2', 'D2', 'L2', 'R2', 'F2', 'B2']).describe("The cube move to execute") },
  • src/app.ts:116-177 (registration)
    MCP tool registration call for 'manipulateCube', specifying name, description, input schema, and handler function.
    "manipulateCube", "Execute a move on the Rubik's Cube", { gameId: z.string().describe("The game session ID"), move: z.enum(['U', 'D', 'L', 'R', 'F', 'B', 'U\'', 'D\'', 'L\'', 'R\'', 'F\'', 'B\'', 'U2', 'D2', 'L2', 'R2', 'F2', 'B2']).describe("The cube move to execute") }, async ({ gameId, move }: { gameId: string; move: string }) => { const game = this.games.get(gameId); if (!game) { throw new Error(`Game session ${gameId} not found`); } const { cube, session } = game; // 이미 해결된 큐브인지 확인 if (session.status === 'completed') { const response: CubeResponse = { gameId, cube: cube.getState(), nextAction: "finish" }; return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } // 움직임 실행 cube.executeMove(move as CubeMove); const newState = cube.getState(); // 세션 업데이트 session.cubeState = newState; session.lastActivity = Date.now(); if (newState.solved) { session.status = 'completed'; } // 시각화 서버 업데이트 this.visualizationServer.updateSession(gameId, newState); const response: CubeResponse = { gameId, cube: newState, nextAction: newState.solved ? "finish" : "manipulateCube" }; return { content: [ { type: "text", text: JSON.stringify(response, null, 2) } ] }; } );
  • Core helper method in RubiksCube class that resolves the move to a function via getMoveFunction and executes it, then updates history and solved status. Used directly in the tool handler.
    executeMove(move: CubeMove): void { const moveFunc = this.getMoveFunction(move); moveFunc(); this.state.moveHistory.push(move); this.state.solved = this.checkSolved(); }
  • TypeScript type definition for CubeMove, used in the tool schema enum and executeMove parameter.
    export type CubeMove = 'U' | 'D' | 'L' | 'R' | 'F' | 'B' | 'U\'' | 'D\'' | 'L\'' | 'R\'' | 'F\'' | 'B\'' | 'U2' | 'D2' | 'L2' | 'R2' | 'F2' | 'B2';
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/fritzprix/rubiks-cube-mcp-server'

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