We study the hydrodynamic limit for the isothermal dynamics of an anharmonic chain under hyperbolic space-time scaling under varying tension. The temperature is kept constant by a contact with a heat bath, realised via a stochastic momentum-preserving noise added to the dynamics. The noise is designed to be large at the microscopic level, but vanishing in the macroscopic scale. Boundary conditions are also considered: one end of the chain is kept fixed, while a time-varying tension is applied to the other end. We show that the volume stretch and momentum converge (in an appropriate sense) to a weak solution of a system of hyperbolic conservation laws (isothermal Euler equations in Lagrangian coordinates) with boundary conditions. This result includes the shock regime of the system. This is proven by adapting the theory of compensated compactness to a stochastic setting, as developed by Fritz (2011 Arch. Ration. Mech. Anal. 201 209-49) for the same model without boundary conditions. Finally, changing the external tension allows us to define thermodynamic isothermal transformations between equilibrium states. We use this to deduce the first and the second principle of thermodynamics for our model.This work has been partially supported by the grants ANR-15-CE40-0020-01 LSD of the French National Research Agency.