Good question. I’m not a doctor, but can give a quick and dirty answer.
Actual dialysis is done in a small cartridge, just like you propose. The pump could be made small too. But I assume you are thinking ahead to implanting it. Turns out there are several things working against you. Dialysis (and kidneys) have tennis court size membranes. Small isn’t a problem, but they have to be replaced regularly. They effectively clog up over time.
There’s also the problem that anything artificial that connects to the outside world will act as a highway for bacteria.
And lastly, dialysis required a high volume of dialysate, which is used to “rinse” the blood. This requires an external supply and drain.
Kidneys themselves actually work differently. They produce about 100L of filtrate a day. They then spend most of their effort reabsorbing all the water, sugar, electrolytes, etc that the body wants to retain. Which is why drinking more water makes the kidney’s work easier.