MCP server for querying DWP Stat-Xplore benefit statistics.
claude mcp add stat-xplore -- uvx --from git+https://github.com/PolicyEngine/stat-xplore-mcp stat-xplore-mcpOn first use, you'll be prompted to enter your API key. Get one from Stat-Xplore under Account > Open Data API Access.
The API key is stored in ~/.config/stat-xplore-mcp/config.json. You can also set it via the STAT_XPLORE_API_KEY environment variable.
list_databases- list all 118 benefit datasets (UC, PIP, ESA, etc.)get_database_schema- get fields and measures for a databasequery_table- query statistics data with full support for dimensions, recodes, and statistical functionsbrowse_schema- navigate the schema hierarchyget_rate_limit- check API rate limit status
{
"database": "str:database:HBAI",
"measures": ["str:count:HBAI:V_F_HBAI"],
"dimensions": [["str:field:HBAI:V_F_HBAI:YEAR"]]
}For median/mean calculations, use statistical function measures with the pattern:
str:statfn:{database}:{view}:{measure}:{MEDIAN|MEAN}
{
"database": "str:database:HBAI",
"measures": [
"str:statfn:HBAI:V_F_HBAI:S_OE_BHC:MEDIAN",
"str:statfn:HBAI:V_F_HBAI:S_OE_AHC:MEDIAN"
],
"dimensions": [
["str:field:HBAI:V_F_HBAI:YEAR"],
["str:field:HBAI:V_F_HBAI:KIDECOBU_WORK"]
],
"recodes": {
"str:field:HBAI:V_F_HBAI:YEAR": {
"map": [
["str:value:HBAI:V_F_HBAI:YEAR:C_HBAI_YEAR:2223"],
["str:value:HBAI:V_F_HBAI:YEAR:C_HBAI_YEAR:2324"]
]
},
"str:field:HBAI:V_F_HBAI:KIDECOBU_WORK": {
"map": [
["str:value:HBAI:V_F_HBAI:KIDECOBU_WORK:C_HBAI_KIDECOBU_WORK:1"]
]
}
}
}Recodes filter and group values:
map: List of value groups. Each inner array becomes one row/column. Multiple values in same array are combined.total: Set totrueto include a total row/column.
{
"str:field:HBAI:V_F_HBAI:NEWFAMBU": {
"map": [
["str:value:...:1"],
["str:value:...:2", "str:value:...:3"]
],
"total": true
}
}