Use pyeconomics with an AI assistant
pyeconomics is an MCP server: an assistant that speaks the Model Context Protocol gets every model and every data series as tools, and answers with the same results this site shows, each with its sources.
Connect it
Most assistants read a JSON configuration file. Add this entry, and the assistant starts the server on your own computer when it needs it:
{
"mcpServers": {
"pyeconomics": {
"command": "uvx",
"args": [
"--prerelease", "allow",
"--from",
"pyeconomics[mcp]",
"pyeconomics", "mcp"
]
}
}
}It runs uvx --prerelease allow --from "pyeconomics[mcp]" pyeconomics mcp, which needs uv installed. The server runs on your own computer and reads your own data keys, as the library does, so it reaches every source you can.
An assistant that connects to a URL can use this site's server instead, with nothing to install: https://pyeconomics.dev/mcp. It serves the same tools over the data this site may serve.
The documentation's MCP page has the command for each client and every option.
The tools
Five tools reach every model and every source:
search_models- finds models by a word, or lists a domain's
describe_model- gives a model's inputs and outputs with their units, and its model card
run_model- runs any model by its id, on the inputs given or on live data
get_series- reads a data series, with its source and the attribution it must be shown with
list_sources- lists every data source with its licence class and terms
16 models also have a tool of their own, which takes the model's inputs alone and gives the same result as run_model with the model's id:
corporate_capital_budgeting: Capital budgetingcorporate_cost_of_capital: Cost of capital and betaderivatives_binomial_tree: Binomial option treederivatives_black_scholes_merton: Black-Scholes-Merton optionsequity_dividend_discount: Dividend discount valuationequity_free_cash_flow: Free cash flow and DCF valuationfixed_income_bond_pricing: Bond price and yieldfixed_income_curve_bootstrap: Spot, par and forward curvesfixed_income_duration: Bond durationfoundations_returns: Return toolkitfoundations_time_value: Time value of moneyinternational_parity_conditions: International parity conditionsmacro_policy_rule: Monetary-policy rulesperformance_risk_adjusted: Risk-adjusted performanceportfolio_mean_variance: Mean-variance portfoliosrisk_value_at_risk: Value-at-risk and expected shortfall
Every model's page gives its tool under "Use it elsewhere", and its calculator writes the call for the inputs you typed.
What data reaches an assistant
Only data whose terms allow it. Each source declares whether its data may be given to a language model, and the server withholds a series whose source does not; list_sources tells the assistant which are which. The data sources lists every source and its terms.