remove_member
Remove a member from a gathering to update participant lists and maintain accurate expense tracking for social events.
Instructions
Remove a member from a gathering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gathering_id | Yes | ID of the gathering | |
| member_name | Yes | Name of the member to remove |
Implementation Reference
- src/index.ts:362-367 (handler)MCP tool handler for 'remove_member': validates input arguments and appends the corresponding CLI command to be executed via child_process.execAsync.case 'remove_member': if (!isMemberArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid remove_member arguments'); } command += ` remove-member "${args.gathering_id}" "${args.member_name}"`; break;
- src/index.ts:235-252 (schema)Input schema and registration of the 'remove_member' tool in the MCP ListTools response.{ name: 'remove_member', description: 'Remove a member from a gathering', inputSchema: { type: 'object', properties: { gathering_id: { type: 'string', description: 'ID of the gathering', }, member_name: { type: 'string', description: 'Name of the member to remove', }, }, required: ['gathering_id', 'member_name'], }, },
- gatherings.py:440-440 (registration)Registers the handle_remove_member function for the 'remove-member' CLI subcommand in the handlers dictionary."remove-member": handle_remove_member
- gatherings.py:392-416 (handler)CLI handler for 'remove-member': invokes service.remove_member and formats success/error output in JSON or human-readable format.def handle_remove_member(service, args): """Handle the remove-member command.""" try: gathering = service.remove_member(args.gathering_id, args.member_name) result = { "success": True, "removed": { "member_name": args.member_name, "gathering_id": gathering.id, "total_members": gathering.total_members } } if args.json: print(json.dumps(result)) else: print(f"Removed member '{args.member_name}' from gathering '{gathering.id}'") print(f"Total members: {gathering.total_members}") 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
- models.py:258-308 (handler)Core database implementation: validates gathering open status, member existence, no expenses/payments, then deletes member and decrements total_members.def remove_member(self, gathering_id: str, member_name: str) -> None: """ Remove a member from a gathering. Args: gathering_id: The ID of the gathering member_name: The name of the member Raises: ValueError: If the gathering is closed, the member doesn't exist, or the member has expenses/payments """ 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 gathering is open if gathering.status == GatheringStatus.CLOSED: raise ValueError(f"Cannot remove member from closed gathering '{gathering_id}'") # Get the member to remove member = session.query(Member).filter_by(gathering_id=gathering_id, name=member_name).first() if not member: raise ValueError(f"Member '{member_name}' not found in gathering '{gathering_id}'") # Check if member has expenses expenses_count = session.query(Expense).filter_by(member_id=member.id).count() if expenses_count > 0: raise ValueError(f"Cannot remove member '{member_name}' who has recorded expenses") # Check if member has payments payments_count = session.query(Payment).filter_by(member_id=member.id).count() if payments_count > 0: raise ValueError(f"Cannot remove member '{member_name}' who has recorded payments") # Delete the member session.delete(member) # Update the total members count gathering.total_members -= 1 session.commit() except Exception as e: session.rollback() raise e finally: session.close()