add_member
Add a new member to a gathering by specifying the gathering ID and member name to include participants in expense tracking and reimbursement calculations.
Instructions
Add a new member to 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 add |
Implementation Reference
- src/index.ts:217-234 (registration)Registration of the 'add_member' MCP tool, defining its metadata and input schema.{ name: 'add_member', description: 'Add a new member to 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 add', }, }, required: ['gathering_id', 'member_name'], }, },
- src/index.ts:355-360 (handler)Handler for the 'add_member' tool call in the MCP server. Validates arguments and constructs the Python CLI command to execute the operation.case 'add_member': if (!isMemberArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid add_member arguments'); } command += ` add-member "${args.gathering_id}" "${args.member_name}"`; break;
- src/index.ts:286-289 (helper)Type guard helper function used to validate input arguments for the 'add_member' tool.const isMemberArgs = (args: any): args is { gathering_id: string; member_name: string } => typeof args === 'object' && args !== null && typeof args.gathering_id === 'string' && typeof args.member_name === 'string';
- models.py:212-257 (handler)Core implementation of adding a member in the database layer (DatabaseManager.add_member), called by the service.def add_member(self, gathering_id: str, member_name: str) -> Member: """ Add a member to a gathering. Args: gathering_id: The ID of the gathering member_name: The name of the member Returns: The created Member object Raises: ValueError: If the gathering doesn't exist or is closed, or the member already exists """ 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 add member to closed gathering '{gathering_id}'") # Check if member already exists existing_member = session.query(Member).filter_by(gathering_id=gathering_id, name=member_name).first() if existing_member: raise ValueError(f"Member '{member_name}' already exists in gathering '{gathering_id}'") # Create the member member = Member(name=member_name, gathering_id=gathering_id) session.add(member) # Update the total members count gathering.total_members += 1 session.commit() return member except Exception as e: session.rollback() raise e finally: session.close()
- services.py:215-231 (handler)Service layer wrapper for add_member, delegates to DB manager and retrieves updated gathering.def add_member(self, gathering_id: str, member_name: str) -> Tuple[Gathering, Member]: """ Add a new member to an existing gathering. Args: gathering_id: The ID of the gathering member_name: The name of the member to add Returns: Tuple of (updated Gathering, added Member) Raises: ValueError: If the gathering is closed, doesn't exist, or member already exists """ member = self.db_manager.add_member(gathering_id, member_name) gathering = self.get_gathering(gathering_id) return gathering, member