Skip to main content
Glama
freshlife001

Texas Holdem MCP Server

by freshlife001

join_table

Enable AI agents to join a Texas Holdem poker table by specifying player and table IDs using this MCP server tool for seamless game participation.

Instructions

Join a poker table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
player_idYes
table_idYes

Implementation Reference

  • Input schema for the 'join_table' MCP tool, defining required player_id and table_id parameters.
      name: "join_table",
      description: "Join a poker table",
      inputSchema: {
        type: "object",
        properties: {
          player_id: { type: "string" },
          table_id: { type: "string" },
        },
        required: ["player_id", "table_id"],
      },
    },
  • MCP CallTool handler for 'join_table': sends 'joinTable' request to PokerServer via socket.io and appends formatted table state after polling for active player turn.
    else if (request.params.name === "join_table") {
      response = await sendPokerRequest('joinTable', { 
        playerId: args?.player_id,
        tableId: args?.table_id
      });
      view_text = `Player ${args?.player_id} joined table ${args?.table_id}.\n Game state:\n`;
      
      // Get table state after joining
      view_text += await pollUntilPlayerActive(args?.player_id, args?.table_id);
    } 
  • Tool registration in ListToolsRequestHandler, including 'join_table' in the list of available tools with schema.
      return {
        tools: [
          {
            name: "login",
            description: "login and list all tables in the poker game",
            inputSchema: {
              type: "object",
              properties: {
                name: { type: "string" },
              },
              required: ['name'],
            },
          },
          {
            name: "join_table",
            description: "Join a poker table",
            inputSchema: {
              type: "object",
              properties: {
                player_id: { type: "string" },
                table_id: { type: "string" },
              },
              required: ["player_id", "table_id"],
            },
          },
          {
            name: "get_table_status",
            description: "Get the current status of a poker table",
            inputSchema: {
              type: "object",
              properties: {
                player_id: { type: "string" },
                table_id: { type: "string" },
              },
              required: ["player_id", "table_id"],
            },
          },
          {
            name: "leave_table",
            description: "Leave a poker table",
            inputSchema: {
                type: "object",
                properties: {
                  player_id: { type: "string" },
                  table_id: { type: "string" },
                },
                required: ["player_id", "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"],
            },
          },
          {
            name: "action_fold",
            description: "do action fold",
            inputSchema: {
                type: "object",
                properties: {
                  player_id: { type: "string" },
                  table_id: { type: "string" },
                },
                required: ["player_id", "table_id"],
            },
          },
          {
            name: "action_bet",
            description: "do action bet",
            inputSchema: {
              type: "object",
              properties: {
                player_id: { type: "string" },
                table_id: { type: "string" },
                amount: { type: "number" },
              },
              required: ["player_id", "table_id", 'amount'],
            },
          },
          {
            name: "action_raise",
            description: "do action raise",
            inputSchema: {
              type: "object",
              properties: {
                player_id: { type: "string" },
                table_id: { type: "string" },
                amount: { type: "number" },
              },
              required: ["player_id", "table_id", 'amount'],
            },
          },
          {
            name: "action_call",
            description: "do action call",
            inputSchema: {
                type: "object",
                properties: {
                  player_id: { type: "string" },
                  table_id: { type: "string" },
                },
                required: ["player_id", "table_id"],
            },
          },
        ],
      };
    });
  • PokerServer.handleJoinTable: Validates params, retrieves player, calls GameManager.joinTable, returns success response.
    private handleJoinTable(params: any, id: string | number): PokerResponse {
      const { playerId, tableId } = params;
      
      if (!playerId || !tableId) {
        return {
          error: {
            code: -32602,
            message: 'Invalid params: playerId and tableId are required'
          },
          id
        };
      }
      
      const player = this.players.get(playerId);
      if (!player) {
        return {
          error: {
            code: -32602,
            message: `Player with ID ${playerId} not found`
          },
          id
        };
      }
      
      const success = this.gameManager.joinTable(tableId, player);
      if (!success) {
        return {
          error: {
            code: -32603,
            message: `Failed to join table ${tableId}`
          },
          id
        };
      }
      
      return {
        result: {
          success: true,
          tableId,
          playerId
        },
        id
      };
    }
  • GameManager.joinTable: Adds player to table after checking/leaving current table, updates player-table mapping.
    joinTable(tableId: string, player: Player): boolean {
      const table = this.tables.get(tableId);
      if (!table) {
        return false;
      }
      
      // Check if player is already at a table
      if (this.playerTables.has(player.id)) {
        const currentTableId = this.playerTables.get(player.id);
        if (currentTableId === tableId) {
          return true; // Player is already at this table
        }
        
        // Leave current table first
        this.leaveTable(player.id);
      }
      
      const success = table.addPlayer(player);
      if (success) {
        this.playerTables.set(player.id, tableId);
      }
      
      return success;
    }
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