Let $p$ be the minimal polynomial of $A$. Then there is a unique polynomial $s\in K[X]$ of degree less than $\deg p$ such that $s(A)$ is the semi-simple part of $A$.
Assume, as we may, that $p$ splits in $K$ as, say, $ p=\prod_{\lambda\in\Lambda}\ (X-\lambda)^{m(\lambda)} $ with $m(\lambda) > 0$ for all $\lambda$.
Then $s$ is the unique degree less than $\deg p$ solution to the congruences $ s\equiv\lambda\quad\bmod\quad(X-\lambda)^{m(\lambda)},\quad\lambda\in\Lambda, $ and it is given by $ s=\sum_{\lambda\in\Lambda}\ \lambda\ T_\lambda\left(\frac{(X-\lambda)^{m(\lambda)}}{p}\right)\frac{p}{(X-\lambda)^{m(\lambda)}}\quad, $ where $T_\lambda(f)$ means "order less than $m(\lambda)$ Taylor polynomial of $f$ at $\lambda$".
EDIT. Here is a proof. Put $ B_\lambda:=\frac{K[X]}{(X-\lambda)^{m(\lambda)}}\quad. $
(A) We have canonical $K[X]$-algebra isomorphisms $ K[A]\simeq\frac{K[X]}{(p)}\simeq\prod_{\lambda\in\Lambda}\ B_\lambda=:B, $ the second isomorphism being given by the Chinese Remainder Theorem.
We way (and will) work in $B$ instead of working in $K[A]$.
Let $x\in B$ be the canonical image of $X$, and $e_\lambda$ the element of $B$ whose $\lambda$ component is $1$, and whose other components are $0$.
We must find the semi-simple part of $x$. But this is clearly the sum of the $\lambda e_\lambda$. In view of (A), this shows that, as claimed, $s$ is the unique degree less than $\deg p$ solution to the congruences $ s\equiv\lambda\quad\bmod\quad(X-\lambda)^{m(\lambda)},\quad\lambda\in\Lambda, $ and we're left with solving these congruences.
It's not harder to solve the general congruence system $ s\equiv p_\lambda\quad\bmod\quad(X-\lambda)^{m(\lambda)},\quad\lambda\in\Lambda, $ where the $p_\lambda\in K[X]$ are arbitrary.
The trick is to use the Ansatz $ s:=\sum_{\lambda\in\Lambda}\ s_\lambda\ \frac{p}{(X-\lambda)^{m(\lambda)}}\quad,\quad\deg s_\lambda < m(\lambda), $ which gives the solution $ \sum_{\lambda\in\Lambda}\ T_\lambda\left(p_\lambda\ \frac{(X-\lambda)^{m(\lambda)}}{p}\right)\frac{p}{(X-\lambda)^{m(\lambda)}}\quad. $
[Recall that $A$ admits a Jordan decomposition if and only if its eigenvalues are separable over $K$ (Bourbaki, Algèbre, Théorème VII.5.9.1). We assume here that such is the case.]