There’s no evidence for any kind of political intent in Kafka’s work. The Trial seems to have been inspired by a confrontation between Kafka and Felice Bauer’s family, who were becoming quite naturally pissed off by Franz’s refusal to make an honest woman of his girlfriend. Because of Kafka’s Jewish ancestry, Metamorphosis is generally thought to be a commentary on anti-semitism, but even though all three of Kafka’s sisters and many of his friends perished in the camps, at the time he was writing, the Czech working classes were firmly the underdogs in his social milieu and the concept of Untermenschno more than a twinkle in Hitler’s eye. It’s more likely that Kafka had read Freud and came to the story as an expression of his conflicted emotions about his own sexual urges (yes, he wrote a scad of letters on that subject too).
However, in the post war years and interpreted through the telescope of history, these books became transformed into a solemn commentary on Things to Come. Kafka became a literary superstar, identified as an influence on luminaries such as Camus, Sartre and Ray Bradbury.