You can easily calculate it with DMAP and MDM tools. If you want calculate SPI for middle-East by AgMERRA precipitation data with 0.25degree*0.25degree resolution, by using MDM tool you can compute SPI very soon an get Excel files for your outputs.
See the bellow links which are so useful and you can also customize your demand through the link.
There is several gauges that you can use it such as AgMerra, CPC, TRMM, Gleam, .... but the format of data in all gauges is netcdf and you can use Netcdf-Extractor and "Open NC File" for extract data from netcdf files. Also you can use Matlab, NCl, NCO, etc.
In other hands, there is a paper in researchgate that use AgMerra for calculating 8 drought indices.