Skip to main content
Glama
abutbul

Gatherings MCP Server

by abutbul

close_gathering

End a social event tracking session to finalize expense calculations and settle balances between participants.

Instructions

Close a gathering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gathering_idYesID of the gathering to close

Implementation Reference

  • MCP tool schema definition including input schema for close_gathering
    {
      name: 'close_gathering',
      description: 'Close a gathering',
      inputSchema: {
        type: 'object',
        properties: {
          gathering_id: {
            type: 'string',
            description: 'ID of the gathering to close',
          },
        },
        required: ['gathering_id'],
      },
    },
  • MCP CallToolRequest handler for close_gathering: validates arguments and constructs CLI command to execute gatherings.py close
    case 'close_gathering':
      if (!isGatheringIdArg(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid close_gathering arguments');
      }
      command += ` close "${args.gathering_id}"`;
      break;
  • CLI handler function for 'close' subcommand invoked by MCP server, calls service.close_gathering and formats output
    def handle_close(service, args):
        """Handle the close command."""
        try:
            gathering = service.close_gathering(args.gathering_id)
            result = {
                "success": True,
                "gathering": {
                    "id": gathering.id,
                    "status": gathering.status.value
                }
            }
            if args.json:
                print(json.dumps(result))
            else:
                print(f"Closed gathering: {gathering.id}")
                print(f"Status: {gathering.status.value}")
            return True
        except ValueError as e:
            error = {"success": False, "error": str(e)}
            if args.json:
                print(json.dumps(error))
            else:
                print(f"Error: {e}")
            return False
  • GatheringService wrapper method that delegates close_gathering to DatabaseManager
    def close_gathering(self, gathering_id: str) -> Gathering:
        """
        Close a gathering.
        
        Args:
            gathering_id: The ID of the gathering
            
        Returns:
            The updated Gathering object
            
        Raises:
            ValueError: If the gathering doesn't exist or is already closed
        """
        return self.db_manager.close_gathering(gathering_id)
  • Core DatabaseManager implementation: fetches gathering, validates, updates status to CLOSED, commits transaction.
    def close_gathering(self, gathering_id: str) -> Gathering:
        """
        Close a gathering.
        
        Args:
            gathering_id: The ID of the gathering
            
        Returns:
            The updated Gathering object
            
        Raises:
            ValueError: If the gathering doesn't exist or is already closed
        """
        session = self.Session()
        try:
            # Get the gathering
            gathering = session.query(Gathering).filter_by(id=gathering_id).first()
            if not gathering:
                raise ValueError(f"Gathering '{gathering_id}' not found")
            
            # Check if already closed
            if gathering.status == GatheringStatus.CLOSED:
                raise ValueError(f"Gathering '{gathering_id}' is already closed")
            
            # Close the gathering
            gathering.status = GatheringStatus.CLOSED
            
            session.commit()
            
            # Return a fresh copy of the gathering
            return self.get_gathering(gathering_id)
            
        except Exception as e:
            session.rollback()
            raise e
        finally:
            session.close()

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/abutbul/gatherings-mcp'

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