rename_member
Update a member's name in a gathering by specifying the gathering ID, current name, and new name for accurate expense tracking and reimbursements.
Instructions
Rename an unnamed member
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gathering_id | Yes | ID of the gathering | |
| new_name | Yes | New name for the member | |
| old_name | Yes | Current name of the member |
Implementation Reference
- src/index.ts:323-328 (handler)MCP tool handler: validates input arguments and constructs the Python CLI command to execute rename-member.case 'rename_member': if (!isRenameMemberArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid rename_member arguments'); } command += ` rename-member "${args.gathering_id}" "${args.old_name}" "${args.new_name}"`; break;
- src/index.ts:141-161 (schema)Input schema definition for the rename_member MCP tool.name: 'rename_member', description: 'Rename an unnamed member', inputSchema: { type: 'object', properties: { gathering_id: { type: 'string', description: 'ID of the gathering', }, old_name: { type: 'string', description: 'Current name of the member', }, new_name: { type: 'string', description: 'New name for the member', }, }, required: ['gathering_id', 'old_name', 'new_name'], }, },
- gatherings.py:210-232 (handler)CLI command handler for 'rename-member': calls service.rename_member and outputs JSON or text result.def handle_rename_member(service, args): """Handle the rename-member command.""" try: member = service.rename_member(args.gathering_id, args.old_name, args.new_name) result = { "success": True, "member": { "old_name": args.old_name, "new_name": member.name } } if args.json: print(json.dumps(result)) else: print(f"Renamed member from '{args.old_name}' to '{member.name}'") 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
- gatherings.py:429-441 (registration)Registers the handle_rename_member function for the 'rename-member' CLI command in the handlers dictionary.handlers = { "create": handle_create, "add-expense": handle_add_expense, "calculate": handle_calculate, "record-payment": handle_record_payment, "rename-member": handle_rename_member, "show": handle_show, "list": handle_list, "close": handle_close, "delete": handle_delete, "add-member": handle_add_member, "remove-member": handle_remove_member }
- models.py:489-545 (handler)Core database implementation: updates member name in the database after validation.def rename_member(self, gathering_id: str, old_name: str, new_name: str) -> Member: """ Rename a member in a gathering. Args: gathering_id: The ID of the gathering old_name: The current name of the member new_name: The new name for the member Returns: The updated Member object Raises: ValueError: If the gathering is closed, the member doesn't exist, or the new name is already taken """ 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 rename member in closed gathering '{gathering_id}'") # Get the member to rename member = session.query(Member).filter_by(gathering_id=gathering_id, name=old_name).first() if not member: raise ValueError(f"Member '{old_name}' not found in gathering '{gathering_id}'") # Check if new name already exists existing_member = session.query(Member).filter_by(gathering_id=gathering_id, name=new_name).first() if existing_member: raise ValueError(f"Member '{new_name}' already exists in gathering '{gathering_id}'") # Update the member name member.name = new_name session.commit() # Get a fresh copy of the gathering updated_gathering = self.get_gathering(gathering_id) # Find the member in the updated gathering for m in updated_gathering.members: if m.name == new_name: return m raise ValueError(f"Cannot find member '{new_name}' after renaming") except Exception as e: session.rollback() raise e finally: session.close()