Skip to content

Commit 56b8c71

Browse files
Apply suggestion from @Copilot
Co-authored-by: Copilot <[email protected]>
1 parent 9bce68f commit 56b8c71

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mcp-server/src/handlers/tool-handlers.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,23 @@ async function createGameWithElicitation(gameType: string, gameId?: string, serv
196196
difficulty: toolArgs?.difficulty,
197197
playerSymbol: toolArgs?.playerSymbol,
198198
maxRounds: toolArgs?.maxRounds
199-
})
199+
// Validate toolArgs properties before passing them
200+
const elicitationOptions: Record<string, unknown> = { gameId };
201+
if (toolArgs) {
202+
if (typeof toolArgs.playerName === 'string') {
203+
elicitationOptions.playerName = toolArgs.playerName;
204+
}
205+
if (typeof toolArgs.difficulty === 'string') {
206+
elicitationOptions.difficulty = toolArgs.difficulty;
207+
}
208+
if (typeof toolArgs.playerSymbol === 'string') {
209+
elicitationOptions.playerSymbol = toolArgs.playerSymbol;
210+
}
211+
if (typeof toolArgs.maxRounds === 'number') {
212+
elicitationOptions.maxRounds = toolArgs.maxRounds;
213+
}
214+
}
215+
const elicitationResult = await elicitGameCreationPreferences(server, gameType, elicitationOptions)
200216

201217
if (elicitationResult.action === 'decline' || elicitationResult.action === 'cancel') {
202218
return {

0 commit comments

Comments
 (0)