Skip to main content
Glama
freshlife001

Texas Holdem MCP Server

by freshlife001

action_check

Perform a check action in Texas Holdem poker games by specifying the player and table IDs using the MCP server interface.

Instructions

do action check

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
player_idYes
table_idYes

Implementation Reference

  • Handler for the 'action_check' MCP tool. Sends a 'performAction' request with action 'check' to the poker server via socket.io, updates view_text with action confirmation, and appends the formatted updated table state after polling until the player is active.
    else if (request.params.name === "action_check") {
      response = await sendPokerRequest('performAction', { 
        playerId: args?.player_id,
        tableId: args?.table_id,
        action: 'check' 
      });
      view_text = `Player ${args?.player_id} action: Check\n Game state:\n`;
      
      // Get updated table state
      view_text += await pollUntilPlayerActive(args?.player_id, args?.table_id);
    } 
  • src/mcpServer.ts:78-90 (registration)
    Registration of the 'action_check' tool in the ListToolsRequestHandler response, including its description and input schema requiring player_id and table_id.
    {
      name: "action_check",
      description: "do action check",
      inputSchema: {
          type: "object",
          properties: {
            player_id: { type: "string" },
            table_id: { type: "string" },
          },
          required: ["player_id", "table_id"],
      },
    },
    {
  • Helper function used by action_check (and other tools) to send requests to the underlying poker server via socket.io.
    function sendPokerRequest(method: string, params: any): Promise<any> {
      return new Promise((resolve, reject) => {
        const request = {
          method,
          params,
          id: Date.now()
        };
        
        //console.log(`[Client] Sending request: ${method}`, params);
        
        socket.emit('action', request, (response: any) => {
          //console.log(`[Client] Received response for ${method}:`, response);
          
          if (response.error) {
            console.error(`[Client] Error in ${method}:`, response.error);
            reject(response.error);
          } else {
            resolve(response.result);
          }
        });
      });
    }
  • Helper function used by action_check (and other action tools) to poll the table state until the current player is active, then formats and returns the table state.
    async function pollUntilPlayerActive(player_id:unknown, table_id:unknown) {
        let tableState = null;
        let counter = 0;
        while(true) {
            tableState = await sendPokerRequest('getTableState', { 
                playerId: player_id,
                tableId: table_id 
            });
            counter ++;
            if (counter > 120) {
                break
            }
            
            const currentPlayer = tableState.players.find((p: any) => p.isActive);
            if (currentPlayer && currentPlayer.id === player_id) {
                break;
            }
            await sleep(1000);
        }
    
        if (tableState === null) {
            return '';
        }
    
        return formatTableState(tableState);
    }
  • Helper function to format the table state into a readable string, used in the response after action_check.
    function formatTableState(tableState: any): string {
      if (!tableState) return "No table state available.";
      
      let result = `Table: ${tableState.name} (ID: ${tableState.id})\n`;
      result += `Stage: ${tableState.stage}\n`;
      result += `Pot: $${tableState.pot}\n`;
      result += `Current Bet: $${tableState.currentBet}\n`;
      
      // Find the current active player
      const currentPlayer = tableState.players.find((p: any) => p.isActive);
      if (currentPlayer) {
        result += `Current Player: ${currentPlayer.name} (ID: ${currentPlayer.id})\n`;
      }
      
      // Community cards
      result += `Community Cards: ${tableState.communityCards.join(', ') || 'None'}\n\n`;
      
      // Players
      result += "Players:\n";
      tableState.players.forEach((player: any) => {
        result += `- ${player.name}: $${player.chips} chips`;
        
        if (player.isDealer) result += " (Dealer)";
        if (player.isSmallBlind) result += " (Small Blind)";
        if (player.isBigBlind) result += " (Big Blind)";
        if (player.isActive) result += " (Active)";
        if (player.folded) result += " (Folded)";
        if (player.isAllIn) result += " (All-In)";
        
        result += ` - Bet: $${player.bet}\n`;
        
        // Show hand if available
        if (player.hand && player.hand.length > 0) {
          result += `  Hand: ${player.hand.join(', ')}\n`;
        }
      });
      
      return result;
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

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/freshlife001/mcp_poker'

If you have feedback or need assistance with the MCP directory API, please join our Discord server