mcp · cli · python
Run a model your way.
Three routes to the same models. Start with MCP below — it needs no install, no PolicyEngine account and no API key, though some clients gate custom connectors by plan. That is true of the hosted route; a local UK population or reform-scoring run additionally needs a HuggingFace token, as below. Use the CLI or Python when you want the models in a script, or need one of the local-only members.
Connect in three steps.
Copy the server URL
https://policyengine--policyengine-macro-mcp-serve.modal.run/mcpAdd a Claude connector
On claude.ai or in the Claude Desktop app, open Settings → Connectors, choose “Add custom connector”, and paste the URL.
Add a ChatGPT connector
On an eligible ChatGPT web plan, enable Developer mode in Settings → Apps → Advanced Settings, create a custom app, and paste the URL. Workspace admins may need to grant access.
Add a remote MCP server
Add the URL as a remote (HTTP) MCP server — Gemini CLI, Cursor, VS Code, Windsurf, Mistral Le Chat, and any other MCP-capable client. Look for “MCP servers” or “connectors” in its settings.
Ask a policy question
A US rate shock, a UK forecast, a household reform — copy an example prompt below.
- calculate_household
How much tax would a single 35-year-old earning $50,000 pay in the US? - score_reform
Score raising the UK basic rate of income tax to 21p. - forecast_uk
What is the UK GDP and inflation outlook for the next four quarters? - frbus_shock
What happens to US GDP and unemployment if the Fed raises rates by 100 basis points? - hank_shock
How does a 25 basis point US rate cut hit households across the wealth distribution?
Terminal setup
claude mcp add --transport http policyengine-macro https://policyengine--policyengine-macro-mcp-serve.modal.run/mcpFor Codex CLI, register the same MCP endpoint:
codex mcp add policyengine-macro --url https://policyengine--policyengine-macro-mcp-serve.modal.run/mcpFor the Gemini CLI, register the same MCP endpoint:
gemini mcp add --transport http policyengine-macro https://policyengine--policyengine-macro-mcp-serve.modal.run/mcpaccess No account, no API key. Fair use, a few concurrent runs.
cold start ~20s on the first household or population call while the tax-benefit models load; a couple of minutes for a first UK forecast. Warm calls are fast.
uk microdata
Only a local UK population or reform score needs
HUGGING_FACE_TOKEN (private
policyengine-uk-data-private). Hosted calls need
nothing.
local only
Three things are not hosted: model='og' and
dynamic_reform_impact (tens of minutes), and the
define_* tools (unlicensed upstream). Called here they
return run instructions or an import error, not results — use the
CLI. Everything else runs hosted.
Run the shared CLI.
Install once, then choose a model command.
pip install "policyengine-macro[models] @ git+https://github.com/PolicyEngine/macro#subdirectory=integration"pe-macro household --country us --people '[{"age":35,"employment_income":50000}]'pe-macro score --country uk --reform '{"gov.hmrc.income_tax.rates.uk[0].rate":0.21}' --model obrpe-macro forecastpe-macro frbus-shock --var rffintay_aerr --shock 1.0pe-macro hank-shock --kind monetary --size -0.0025View every CLI command → · How the micro-to-macro scoring pipeline works: score a reform.
Use Python directly.
Choose a model for its install and API reference.
UK and US household impacts
Taxes, benefits, net income and reform effects, household by household — PolicyEngine’s own engine, and the usual starting point. It cannot answer GDP, inflation, interest rates or macro feedback; the macro models below add those.
Open PolicyEngine setupNear-term UK fiscal effects
Trace tax and spending changes against the OBR baseline.
Open OBR setupUK forecasts and shock decomposition
Forecast GDP and inflation or explain what moved them.
Open SVAR setupUS monetary and fiscal shocks
Run frb-us impulse responses under a chosen policy rule.
Open frb-us setupUS shocks across the wealth distribution
Run stylized HANK shocks with MPC and hand-to-mouth detail.
Open us-hank setupLong-run reform effects
Model work, saving, capital, and public finances over decades.
Open OG-UK setupDynamic reform scoring
Experimental, UK only: an OG-UK steady-state solve feeds long-run wage changes back into a second microsimulation run. Local only, and until OG-UK#68 the solve needs its own environment — run pe-macro og-score --reform '{"gov.hmrc.income_tax.rates.uk[0].rate":0.21}' --json > og.json there, then pe-macro dynamic-score --reform '{"gov.hmrc.income_tax.rates.uk[0].rate":0.21}' --og-payload og.json — both steps need the same --reform.
UK climate-policy scenarios
Experimental: pip install git+https://github.com/PolicyEngine/define-uk-model fetches the pinned upstream at runtime. That upstream is unlicensed and is never hosted, so scenario deltas come from a cached local run — a fresh one needs local R.