Skip to main content
Glama
freshlife001

Texas Holdem MCP Server

by freshlife001

leave_table

Use this tool to exit a poker table on the Texas Holdem MCP Server by specifying the player ID and table ID to remove a player from the game.

Instructions

Leave a poker table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
player_idYes
table_idYes

Implementation Reference

  • MCP tool handler for 'leave_table': invokes internal 'leaveTable' RPC on PokerServer with playerId and tableId, sets response text.
    else if (request.params.name === "leave_table") {
      response = await sendPokerRequest('leaveTable', {
        playerId: args?.player_id,
        tableId: args?.table_id
      });
      view_text = `Player ${args?.player_id} left table ${args?.table_id}. Game state:\n`;
    } 
  • Input schema for 'leave_table' tool as defined in the listTools response.
    {
      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"],
      },
    },
  • Tool registration in the ListToolsRequest handler, including 'leave_table' among other tools.
      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 RPC handler for 'leaveTable', called by MCP tool. Validates playerId and calls GameManager.leaveTable.
    private handleLeaveTable(params: any, id: string | number): PokerResponse {
      const { playerId } = params;
      
      if (!playerId) {
        return {
          error: {
            code: -32602,
            message: 'Invalid params: playerId is required'
          },
          id
        };
      }
      
      const success = this.gameManager.leaveTable(playerId);
      
      return {
        result: {
          success
        },
        id
      };
    }
  • GameManager method implementing table leaving logic: finds player's table and removes them from it.
    leaveTable(playerId: string): boolean {
      const tableId = this.playerTables.get(playerId);
      if (!tableId) {
        return false;
      }
      
      const table = this.tables.get(tableId);
      if (!table) {
        this.playerTables.delete(playerId);
        return false;
      }
      
      const success = table.removePlayer(playerId);
      if (success) {
        this.playerTables.delete(playerId);
        
        // Comment out or remove this code that deletes empty tables
        // If table is empty, remove it
        // if (table.players.length === 0) {
        //   this.tables.delete(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