Improvisation, or improv, boils down to having a basic knowledge of music theory and some moderate amount of talent or skill. Musicians often have jam sessions where friends play anything that tickles their fancy. It can be done in any situation, but for our purposes we will consider mostly the context of improvisation within a jam session.
Improvising 101 
Unlike other wind instruments, Harmonica can play true chords easily, as well as some "fake chords" (properly speaking, intervals that suggest chords) and aggrepio chords. Also, Harmonica can play melody with self accompaniment, especially on European Tremolos and Diatonics, where the self accompaniment is a true chord. As such, one can improvise easily around chord progression, or around the melody of the song.
There is also a basic approach to improvising which is more simple than playing over a chord accompaniment. It also predates Western tuning systems and chords. It is produced by playing a moving melody on one higher-pitched note, while leaving a lower note ringing as a drone. This can be done on harmonica by combining techniques of octave and embrochure-variation techniques such that one note stay as drone while the other become melody. Best note to use as drone in a Blues harp is the fifth note of the harmonica's key; this is because the note exist in both the second-hole draw and third-hole blow, allowing the drone exist for the entire duration. For chromatic, one can only do it on a classical-tuned, with drone as the first note of the key.
Other methods are using slaps, pull, side-pull, pull-slaps, and other self-accpmaniment techniques. Of course, it's going to sound different from the drone, as the self accompaniment notes varies, and also follow along the melodic note as you played. This, however, still sound rich (and some even to say much richer than drones), creating both simple harmonic and melodic motion. It can be heard in many musical styles in both Eastern and Western musical traditions.
This technique can be found both within Western tuning systems which use 12 semitones per octave as well as beyond in more complex Eastern tuning systems. Therefore before attempting to improvise a solo over a chord progression or a series of chords in a particular key, it is useful to practice playing simple two-hole intervals as melodies to familiarize your ear. Another advantage of this is that with each pair of notes you play, different intervals are sounded. Your ear begins to detect these and this is a basic form of ear training.
Staying in the right key 
Suppose you are playing in a jam session and are playing with a rhythm section. When playing with two instruments that are improvising you will have your rhythm guitarist play a set run in a certain key. For example, the rhythm guitarist might be playing a three chord blues riff in the key of B minor. You can often figure out the key that is being played by ear based on the first chord played. If you were to play a small solo, you should stick to a B minor scale such as the B minor blues scale. Any style of scale — modal, pentatonic, etc. — can be used and each one will give a different flavor to your improvisation. For example, the Phrygian mode has traditionally been the "Spanish scale".
The key to improvisation is to listen to the interplay of the rest of the instruments, and to add to that whatever sounds best. This is, unfortunately, a very neglected practice among beginning musicians, and, really, musicians of all stripes in general.
A common tendency, especially among those who have just begun to get a solid foundation in scale theory and technique, is to noodle around up and down on the mouthpiece aimlessly with little or no regard for the shape of the song that is being played or the structure of the arrangement. This is a mistake, and it leads to music that no one wants to listen to; worse yet, it quickly runs out, and does nothing to develop the musician who plays it.
Listen to the music that is being played around you. Add to it only when it is necessary. You should begin to hear the lines that you want to play before you play them. What you are shooting here is something akin to the old koan about sculpting: the figure is already in the marble, and you are just trying to release it.
It is also important to make sure that you do not take up too much "space" in the arrangement, which is to say, do not play so loudly that other instruments must fight to be heard.
Guidlines of Jam sessions 
In theory, Jam sessions is nothing more than a practice session to practice improvisions, and thus, should play whatever sounds good.
In practice, what sounds good differs from one session to another.
Reference from Guitar:Improvising
|Getting started: Why should I Play Harmonica? | Types of harmonica | Anatomy of a Harmonica | Harmonica Purchasing guide|
|Playing the harmonica: Basic Holding and Playing a Harmonica | Tablature | Basic Chords | Bending|
|Additional techniques: Advance Chords | Advance techniques | Self accompaniment|
|General harmonica theory: Chromatic Harmonica | Positions | Tremelo | Ensemble Playing | Music Style | Learning Songs | Improvising | Recording | Playing with Amp|
|Cleaning and maintainence: Basic Maintainence and Care | Advance Maintainence |Harmonica Modifications |Tuning|
|Appendices: Harmonica Layouts and Alternate Tunings| Harmonica Positions Chart | Blues | Writing Songs|