Metadata-Version: 2.4
Name: pyvar-mcp
Version: 0.2.2
Summary: MCP server exposing pyvar.com's 385 risk functions as Claude Code tools
Author: Fibtec Limited
License: Apache-2.0
Project-URL: Homepage, https://www.pyvar.com
Project-URL: Repository, https://github.com/fibtecltd/pyvar
Project-URL: Bug Tracker, https://github.com/fibtecltd/pyvar/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<3,>=2.1.0
Requires-Dist: anyio>=4.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black==26.5.1; extra == "dev"
Requires-Dist: isort==8.0.1; extra == "dev"
Requires-Dist: ruff==0.15.22; extra == "dev"
Dynamic: license-file

# pyvar-mcp

MCP server exposing all 385 [pyvar.com](https://www.pyvar.com) risk
functions — VaR, credit risk, derivatives, liquidity, operational risk,
portfolio analytics, ALM, regulatory capital — as Claude Code tools.

It's a thin wrapper over the live pyvar API (each tool call is a real HTTPS
request), not a bundled copy of the compute engine — results always match
what's actually deployed at pyvar.com.

## Install

```
/plugin marketplace add fibtecltd/pyvar
/plugin install pyvar-mcp@pyvar-marketplace
```

You'll be prompted for a pyvar API key during install. Sign in at
<https://www.pyvar.com#get-api-key> (emailed link or Google; no password, no
credit card) and create one on the dashboard. It starts with `pyvar_`, lasts a
year, and you can revoke it there at any time.

The plugin starts the server with `uvx pyvar-mcp`, which downloads it from PyPI
on first use, so it needs [uv](https://docs.astral.sh/uv/) on your PATH. If the
tool calls fail with a "command not found" style error, a missing uv is almost
certainly why. No uv? Run `pip install pyvar-mcp` and change the plugin's
`mcpServers` command to `pyvar-mcp` (with no `args`). Working from a checkout of
this repo instead: `pip install -e plugins/mcp`.

`pyvar-mcp` is published to PyPI by `.github/workflows/pyvar-mcp-publish.yml`
when a `pyvar-mcp-v*` tag is pushed (trusted publishing; the tag must equal the
version in `pyproject.toml`).

## Tools

Two generic tools, meant as your first choice:

- **`list_pyvar_functions(domain?)`** — browse available functions, optionally
  filtered to one domain (`alm`, `credit-risk`, `derivatives`, `liquidity`,
  `market-risk`, `operational`, `portfolio`, `regulatory`).
- **`call_pyvar_function(domain, function_name, params)`** — call any
  function by name. Validates `params` against the function's own schema
  before calling the API.

Plus all 385 functions as individually named tools (`alm_stress_test`,
`historical_simulation_var`, etc.) with precise per-parameter schemas, for
when you already know exactly which one you want.

## Local development

```
cd plugins/mcp
pip install -e ".[dev]"
pytest
```

Regenerating the tool catalogue after `portal/functions.json` changes:

```
python3 scripts/generate_mcp_tools.py   # from the repo root
```

`.github/workflows/plugins-ci.yml` fails CI if the committed `pyvar_mcp/_generated/`
doesn't match what regenerating produces — same drift-check pattern the skills plugins
and `pyvar-client` use. The catalogue is one module per domain, not one file: the plugin
directory's safety scan reads a file in full only up to 256 KiB, and the generator refuses to
write a file over 200,000 bytes (the largest today is about 78,000).
