Exclusive

Tekashi 6ix9ine has more strings attached to his prison sentence, and they're aimed at helping him out ... and helping the feds out.

The rapper's been ordered by the court to enroll in an outpatient mental health program once he's free ... according to new legal docs obtained by TMZ. As we reported, his release is potentially not too far off ... as early as next August.

In addition, 6ix9ine must continue to cooperate with the U.S. Attorney's Office once he's released from prison in any ongoing investigations where he might be useful.

As for his incarceration ... there's some good news for him. The court's recommended Tekashi be placed in a correctional facility as close to New York City as possible -- so his family can easily visit him.

As we reported ... the rapper was sentenced Wednesday to 24 months in his racketeering case. However, he's already served 13 months ... so he could be out by late 2020 if all goes well for him.