Skip to main content
Glama
fritzprix

Rubik's Cube MCP Server

by fritzprix

startCube

Initialize a Rubik's Cube game session with customizable scramble options for AI agents to solve puzzles using standard notation moves.

Instructions

Initialize a new Rubik's Cube game session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scrambleNoWhether to scramble the cube initially
difficultyNoNumber of scramble moves (1-100)

Implementation Reference

  • Executes the startCube tool: creates a new game session with RubiksCube, scrambles if requested, sets up visualization, generates game ID and UI link.
    async ({ scramble = true, difficulty = 20 }: { scramble?: boolean; difficulty?: number }) => {
      const gameId = `cube_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
      const cube = new RubiksCube();
    
      if (scramble) {
        cube.scramble(difficulty);
      }
    
      const session: GameSession = {
        id: gameId,
        cubeState: cube.getState(),
        createdAt: Date.now(),
        lastActivity: Date.now(),
        status: 'active',
        scrambleMoves: difficulty
      };
    
      this.games.set(gameId, { cube, session });
      this.visualizationServer.registerSession(session);
    
      const currentState = cube.getState();
      const response: CubeResponse = {
        gameId,
        cube: currentState,
        scrambleMoves: difficulty,
        nextAction: currentState.solved ? "finish" : "manipulateCube"
      };
    
      // MCP UI 리소스 생성 (예: 게임 링크)
      const gameUrl = `http://localhost:3000/game/${gameId}`;
      const uiResponse = {
        type: "resource",
        resource: {
          uri: `ui://game-link/${gameId}`,
          mimeType: "text/html",
          text: `<a href="${gameUrl}" target="_blank">Click to Play!</a>`
        }
      } as const;
    
      return {
        content: [
          uiResponse,
          { type: "text", text: JSON.stringify(response, null, 2) }
        ]
      };
    }
  • Zod input schema for the startCube tool parameters.
    {
      scramble: z.boolean().optional().describe("Whether to scramble the cube initially"),
      difficulty: z.number().min(1).max(100).optional().describe("Number of scramble moves (1-100)")
    },
  • src/app.ts:28-80 (registration)
    Registers the startCube tool with the MCP server, specifying name, description, input schema, and handler function.
      "startCube",
      "Initialize a new Rubik's Cube game session",
      {
        scramble: z.boolean().optional().describe("Whether to scramble the cube initially"),
        difficulty: z.number().min(1).max(100).optional().describe("Number of scramble moves (1-100)")
      },
      async ({ scramble = true, difficulty = 20 }: { scramble?: boolean; difficulty?: number }) => {
        const gameId = `cube_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
        const cube = new RubiksCube();
    
        if (scramble) {
          cube.scramble(difficulty);
        }
    
        const session: GameSession = {
          id: gameId,
          cubeState: cube.getState(),
          createdAt: Date.now(),
          lastActivity: Date.now(),
          status: 'active',
          scrambleMoves: difficulty
        };
    
        this.games.set(gameId, { cube, session });
        this.visualizationServer.registerSession(session);
    
        const currentState = cube.getState();
        const response: CubeResponse = {
          gameId,
          cube: currentState,
          scrambleMoves: difficulty,
          nextAction: currentState.solved ? "finish" : "manipulateCube"
        };
    
        // MCP UI 리소스 생성 (예: 게임 링크)
        const gameUrl = `http://localhost:3000/game/${gameId}`;
        const uiResponse = {
          type: "resource",
          resource: {
            uri: `ui://game-link/${gameId}`,
            mimeType: "text/html",
            text: `<a href="${gameUrl}" target="_blank">Click to Play!</a>`
          }
        } as const;
    
        return {
          content: [
            uiResponse,
            { type: "text", text: JSON.stringify(response, null, 2) }
          ]
        };
      }
    );

Tool Description Quality Score

Score is being calculated. Check back soon.

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