Skip to main content
Glama
fritzprix
by fritzprix

finish

End a Rubik's Cube solving session by submitting the game ID. This tool ensures proper closure and tracking of progress within the Rubik's Cube MCP Server.

Instructions

Complete the Rubik's Cube game session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gameIdYesThe game session ID

Implementation Reference

  • Handler function for the 'finish' tool. Retrieves the game session, marks it as completed, checks if the cube is solved, generates an appropriate success or failure message, creates a CubeResponse with nextAction null, and returns structured content with the message and JSON response.
    async ({ gameId }: { gameId: string }) => { const game = this.games.get(gameId); if (!game) { throw new Error(`Game session ${gameId} not found`); } const { cube, session } = game; const finalState = cube.getState(); session.status = 'completed'; session.lastActivity = Date.now(); const response: CubeResponse = { gameId, cube: finalState, nextAction: null, }; const message = finalState.solved ? `πŸŽ‰ Congratulations! You solved the cube for game ${gameId}.` : `Game ${gameId} finished. The cube was not solved.` return { content: [ { type: "text", text: message }, { type: "text", text: JSON.stringify(response, null, 2) }, ], }; }
  • Input schema for the 'finish' tool using Zod, validating the required 'gameId' string parameter.
    { gameId: z.string().describe("The game session ID") },
  • src/app.ts:180-215 (registration)
    Registration of the 'finish' MCP tool on the McpServer instance, specifying name, description, input schema, and handler function.
    this.mcpServer.tool( "finish", "Complete the Rubik's Cube game session", { gameId: z.string().describe("The game session ID") }, async ({ gameId }: { gameId: string }) => { const game = this.games.get(gameId); if (!game) { throw new Error(`Game session ${gameId} not found`); } const { cube, session } = game; const finalState = cube.getState(); session.status = 'completed'; session.lastActivity = Date.now(); const response: CubeResponse = { gameId, cube: finalState, nextAction: null, }; const message = finalState.solved ? `πŸŽ‰ Congratulations! You solved the cube for game ${gameId}.` : `Game ${gameId} finished. The cube was not solved.` return { content: [ { type: "text", text: message }, { type: "text", text: JSON.stringify(response, null, 2) }, ], }; } );

Other Tools

Related 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