44
55import { playGame , analyzeGame , waitForPlayerMove , createGame } from './game-operations.js'
66import { elicitGameCreationPreferences } from './elicitation-handlers.js'
7+ import { GAME_TYPES , DIFFICULTIES , isSupportedGameType , DEFAULT_PLAYER_NAME , DEFAULT_AI_DIFFICULTY } from '@turn-based-mcp/shared'
78
89export const TOOL_DEFINITIONS = [
910 {
@@ -18,7 +19,7 @@ export const TOOL_DEFINITIONS = [
1819 } ,
1920 gameType : {
2021 type : 'string' ,
21- enum : [ 'tic-tac-toe' , 'rock-paper-scissors' ] ,
22+ enum : GAME_TYPES ,
2223 description : 'Type of game to play' ,
2324 } ,
2425 } ,
@@ -37,7 +38,7 @@ export const TOOL_DEFINITIONS = [
3738 } ,
3839 gameType : {
3940 type : 'string' ,
40- enum : [ 'tic-tac-toe' , 'rock-paper-scissors' ] ,
41+ enum : GAME_TYPES ,
4142 description : 'Type of game to analyze' ,
4243 } ,
4344 } ,
@@ -56,7 +57,7 @@ export const TOOL_DEFINITIONS = [
5657 } ,
5758 gameType : {
5859 type : 'string' ,
59- enum : [ 'tic-tac-toe' , 'rock-paper-scissors' ] ,
60+ enum : GAME_TYPES ,
6061 description : 'Type of game to monitor' ,
6162 } ,
6263 timeoutSeconds : {
@@ -81,7 +82,7 @@ export const TOOL_DEFINITIONS = [
8182 properties : {
8283 gameType : {
8384 type : 'string' ,
84- enum : [ 'tic-tac-toe' , 'rock-paper-scissors' ] ,
85+ enum : GAME_TYPES ,
8586 description : 'Type of game to create'
8687 } ,
8788 gameId : {
@@ -108,7 +109,7 @@ export async function handleToolCall(name: string, args: any, server?: any) {
108109 if ( ! playGameType ) {
109110 throw new Error ( 'gameType is required' )
110111 }
111- if ( ! [ 'tic-tac-toe' , 'rock-paper-scissors' ] . includes ( playGameType ) ) {
112+ if ( ! isSupportedGameType ( playGameType ) ) {
112113 throw new Error ( `Unsupported game type: ${ playGameType } ` )
113114 }
114115 return await playGame ( playGameType , playGameId )
@@ -143,7 +144,7 @@ export async function handleToolCall(name: string, args: any, server?: any) {
143144 if ( ! genericGameType ) {
144145 throw new Error ( 'gameType is required' )
145146 }
146- if ( ! [ 'tic-tac-toe' , 'rock-paper-scissors' ] . includes ( genericGameType ) ) {
147+ if ( ! isSupportedGameType ( genericGameType ) ) {
147148 throw new Error ( `Unsupported game type: ${ genericGameType } ` )
148149 }
149150 return await createGameWithElicitation ( genericGameType , genericGameId , server )
@@ -162,7 +163,7 @@ export async function handleToolCall(name: string, args: any, server?: any) {
162163async function createGameWithElicitation ( gameType : string , gameId ?: string , server ?: any ) {
163164 if ( ! server ) {
164165 // Fallback to regular creation if no server for elicitation
165- return await createGame ( gameType , 'Player' , gameId , 'medium' )
166+ return await createGame ( gameType , DEFAULT_PLAYER_NAME , gameId , DEFAULT_AI_DIFFICULTY )
166167 }
167168
168169 try {
@@ -228,5 +229,5 @@ async function createGameWithElicitation(gameType: string, gameId?: string, serv
228229 }
229230
230231 // Fallback to regular creation
231- return await createGame ( gameType , 'Player' , gameId , 'medium' )
232+ return await createGame ( gameType , DEFAULT_PLAYER_NAME , gameId , DEFAULT_AI_DIFFICULTY )
232233}
0 commit comments