delete_gathering
Remove a gathering by specifying its ID. Use the force option to delete even if the gathering is closed, ensuring event data is managed effectively on the Gatherings MCP Server.
Instructions
Delete a gathering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Force deletion even if gathering is closed | |
| gathering_id | Yes | ID of the gathering to delete |
Implementation Reference
- models.py:584-615 (handler)Core handler implementing the database deletion logic for the gathering, including existence check, force override for closed gatherings, and cascading deletion of related members, expenses, and payments.def delete_gathering(self, gathering_id: str, force: bool = False) -> None: """ Delete a gathering and all related data. Args: gathering_id: The ID of the gathering force: If True, delete even if the gathering is closed Raises: ValueError: If the gathering doesn't exist or is closed and force is False """ 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 closed and not forced if gathering.status == GatheringStatus.CLOSED and not force: raise ValueError(f"Cannot delete closed gathering '{gathering_id}'. Use --force to override.") # Delete the gathering (cascading delete will handle members, expenses, and payments) session.delete(gathering) session.commit() except Exception as e: session.rollback() raise e finally: session.close()
- services.py:147-158 (handler)Service layer handler that delegates the deletion to the DatabaseManager.def delete_gathering(self, gathering_id: str, force: bool = False) -> None: """ Delete a gathering and all related data. Args: gathering_id: The ID of the gathering force: If True, delete even if the gathering is closed Raises: ValueError: If the gathering doesn't exist or is closed and force is False """ return self.db_manager.delete_gathering(gathering_id, force)
- gatherings.py:342-364 (handler)CLI handler for the 'delete' subcommand invoked by the MCP tool, which calls the service and handles JSON output.def handle_delete(service, args): """Handle the delete command.""" try: service.delete_gathering(args.gathering_id, args.force) result = { "success": True, "deleted": { "gathering_id": args.gathering_id, "forced": args.force } } if args.json: print(json.dumps(result)) else: print(f"Deleted gathering: {args.gathering_id}") 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
- src/index.ts:348-353 (handler)MCP CallTool request handler case for 'delete_gathering', validates arguments and constructs the Python CLI command to invoke the deletion.case 'delete_gathering': if (!isDeleteGatheringArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid delete_gathering arguments'); } command += ` delete "${args.gathering_id}"${args.force ? ' --force' : ''}`; break;
- src/index.ts:199-216 (registration)Registration of the 'delete_gathering' tool in the MCP ListTools response, including description and input schema.name: 'delete_gathering', description: 'Delete a gathering', inputSchema: { type: 'object', properties: { gathering_id: { type: 'string', description: 'ID of the gathering to delete', }, force: { type: 'boolean', description: 'Force deletion even if gathering is closed', default: false, }, }, required: ['gathering_id'], }, },