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';
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'execute[s] a move,' implying a mutation or action, but doesn't clarify if this changes the cube state permanently, requires specific permissions, has side effects, or what happens on failure. This is a significant gap for a mutation tool with zero annotation coverage.

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 a single, efficient sentence that directly states the tool's function without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly, with every word earning its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation with no output schema and no annotations), the description is incomplete. It lacks information on behavioral traits, return values, error handling, and how it integrates with sibling tools, making it inadequate for an agent to use confidently without additional context.

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

Parameters3/5

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

The schema description coverage is 100%, with clear descriptions for both parameters ('gameId' and 'move'), including an enum for valid moves. The description adds no additional meaning beyond what the schema provides, such as explaining move notation or game session context, so it meets the baseline score of 3 when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('execute a move') and the target resource ('on the Rubik's Cube'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its siblings like 'startCube' or 'finish', which likely handle different aspects of cube manipulation, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an active game session from 'startCube' or 'joinGame'), exclusions, or how it relates to sibling tools like 'finish' for ending a session, leaving the agent to infer usage context.

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/fritzprix/rubiks-cube-mcp-server'

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