An expression for the stress tensor near an external boundary of a discrete mechanical system is derived explicitly in terms of the constituents’ degrees of freedom and interaction forces. Starting point is the exact and general coarse graining formulation presented by Goldhirsch (Granul Mat 12(3):239–252, 2010), which is consistent with the continuum equations everywhere but does not account for boundaries. Our extension accounts for the boundary interaction forces in a self-consistent way and thus allows the construction of continuous stress fields that obey the macroscopic conservation laws even within one coarse-graining width of the boundary. The resolution and shape of the coarse-graining function used in the formulation can be chosen freely, such that both microscopic and macroscopic effects can be studied. The method does not require temporal averaging and thus can be used to investigate time-dependent flows as well as static or steady situations. Finally, the fore-mentioned continuous field can be used to define ‘fuzzy’ (very rough) boundaries. Discrete particle simulations are presented in which the novel boundary treatment is exemplified, including chute flow over a base with roughness greater than one particle diameter.