I wrote this script using GIMP bug #88361 as inspiration.
This script provides three functions that expand GIMP's ability to deal with indexed colors. I designed them with pixel artists in mind, who frequently store their target palette as a set of swatches in one region of the image they're working on.
(Image) > Colors > Map > Colormap to palette
Creates a GIMP palette based on an indexed image's colormap, which can then be used just like any normal GIMP palette.
(Image) > Select > Save to palette
Creates a GIMP palette based on the selected region of the current layer.
(Image) > Mode > Indexed from selection...
Converts an image to indexed colors, using only the selected region to define the image's colormap.