1- import type { GameSession } from '../types/game'
2- import type { TicTacToeGameState , RPSGameState } from '../types/games'
1+ import type { GameSession , Player } from '../types/game'
2+ import type { TicTacToeGameState , RPSGameState , TicTacToeMove , RPSMove } from '../types/games'
33import { httpGet , httpPost , WEB_API_BASE } from '../utils/http-client'
44
55// MCP-specific API functions that make HTTP calls to web app
66export async function getTicTacToeGameForMCP ( gameId : string ) : Promise < GameSession < TicTacToeGameState > | undefined > {
77 try {
88 // Get all games and find the one we want
99 const games = await httpGet ( `${ WEB_API_BASE } /api/games/tic-tac-toe` )
10- return games . find ( ( game : any ) => game . gameState ?. id === gameId )
10+ return games . find ( ( game : GameSession < TicTacToeGameState > ) => game . gameState ?. id === gameId )
1111 } catch ( error ) {
1212 console . error ( 'Error fetching tic-tac-toe game via API:' , error )
1313 return undefined
1414 }
1515}
1616
17- export async function createTicTacToeGameForMCP ( players : any [ ] ) : Promise < GameSession < TicTacToeGameState > > {
17+ export async function createTicTacToeGameForMCP ( players : Player [ ] ) : Promise < GameSession < TicTacToeGameState > > {
1818 try {
1919 const playerName = players . find ( p => ! p . isAI ) ?. name || 'Player'
2020 return await httpPost ( `${ WEB_API_BASE } /api/games/tic-tac-toe` , { playerName } )
@@ -24,7 +24,7 @@ export async function createTicTacToeGameForMCP(players: any[]): Promise<GameSes
2424 }
2525}
2626
27- export async function makeTicTacToeMove ( gameId : string , move : any , playerId : string ) : Promise < GameSession < TicTacToeGameState > > {
27+ export async function makeTicTacToeMove ( gameId : string , move : TicTacToeMove , playerId : string ) : Promise < GameSession < TicTacToeGameState > > {
2828 try {
2929 return await httpPost ( `${ WEB_API_BASE } /api/games/tic-tac-toe/${ gameId } /move` , { move, playerId } )
3030 } catch ( error ) {
@@ -36,14 +36,14 @@ export async function makeTicTacToeMove(gameId: string, move: any, playerId: str
3636export async function getRPSGameForMCP ( gameId : string ) : Promise < GameSession < RPSGameState > | undefined > {
3737 try {
3838 const games = await httpGet ( `${ WEB_API_BASE } /api/games/rock-paper-scissors/mcp` )
39- return games . find ( ( game : any ) => game . gameState ?. id === gameId )
39+ return games . find ( ( game : GameSession < RPSGameState > ) => game . gameState ?. id === gameId )
4040 } catch ( error ) {
4141 console . error ( 'Error fetching RPS game via API:' , error )
4242 return undefined
4343 }
4444}
4545
46- export async function makeRPSMove ( gameId : string , move : any , playerId : string ) : Promise < GameSession < RPSGameState > > {
46+ export async function makeRPSMove ( gameId : string , move : RPSMove , playerId : string ) : Promise < GameSession < RPSGameState > > {
4747 try {
4848 return await httpPost ( `${ WEB_API_BASE } /api/games/rock-paper-scissors/${ gameId } /move` , { move, playerId } )
4949 } catch ( error ) {
0 commit comments