Skip to main content
Glama
finreports

finreports

by pragent
README.md
# finreports

Public MCP server for the financial statements of Ukrainian companies, as filed to the State Tax Service (ДПС) and published as open data on [data.gov.ua](https://data.gov.ua/dataset/6456ef0c-985c-4bb7-bf9d-16831161b416): balance sheets, income statements, cash flow and other forms, reporting years 2021+.

**MCP endpoint:** `https://finreports.molesenko.com/mcp` (Streamable HTTP, no auth, rate-limited).
**PDF:** `https://finreports.molesenko.com/reports/<ЄДРПОУ>/<year>.pdf` (`?forms=all` adds cash flow and equity, `&download=1` to save).

## Tools

| Tool | What it does |
|---|---|
| `search_companies` | Find companies by name fragment (typo-tolerant) or ЄДРПОУ prefix; filters by КВЕД, oblast and year |
| `get_financial_summary` | Revenue, net profit, total assets and equity for every year |
| `get_financial_report` | Statements for a year, labelled as on the official forms (line names, codes, columns) |
| `get_report_pdf` | The statements as a PDF laid out like the official blank forms: download link, optionally the file itself (base64) |
| `get_company` | Company card and its authoritative filings |
| `list_filings` | Filings of a company, optionally with superseded resubmissions |
| `get_filing_data` | Figures of one filing, labelled or as raw source tags |
| `list_tables`, `describe_table` | Schema for `run_sql` |
| `run_sql` | One read-only SQL query, row-capped and time-limited |
| `submit_feedback` | Report a problem or request a feature (with the user's consent), written as a reproducible spec |

## Feedback

Reports from `submit_feedback` go to a separate database (`finreports_feedback`). The server's role can only insert them; reading and triage use the owner role:

```bash
npm run feedback -- list                 # new reports
npm run feedback -- show 12              # full report: goal, expected/actual, steps, proposed change, example
npm run feedback -- status 12 done --resolved-in v0.3.0 --notes "labels added"
npm run feedback -- export --status all  # JSON lines
npm run feedback -- test-telegram        # check Telegram notifications
```

If `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID` are set, every new report is posted to that chat.

## Run locally

Needs Node 24+ and PostgreSQL with the `fin_report_govua` database.

```bash
npm ci
cp .env.example .env     # point DATABASE_URL / ADMIN_DATABASE_URL at your database
npm run build && npm run migrate
npm run dev              # http://localhost:3100, MCP at /mcp
npm test                 # unit tests + end-to-end MCP tests (skipped without a database)
```

## Deploy

The server pulls releases itself: `deploy/update.sh` runs every 5 minutes (launchd), and when a new `v*` tag appears it checks it out, builds, migrates, runs the tests, restarts the service and checks `/health`, rolling back on failure. To release:

```bash
npm version patch        # bumps package.json and creates tag vX.Y.Z
git push --follow-tags
```

One-time server setup: `deploy/install.sh` (see the comments inside), plus `deploy/Caddyfile.snippet` for HTTPS.

## Data

Source: ДПС registry dumps on data.gov.ua, published as is, without verification. Figures are in thousands of UAH.

Line names come from the official forms: `data/forms/<family>.json`, built by `tools/forms/build_dictionaries.py` from НП(С)БО 1 (наказ Мінфіну №73, forms 1–4 and the additional articles of додаток 3) and НП(С)БО 25 (form 1-м/2-м); the micro-company form 1-мс/2-мс follows ДПС's own field description, which differs from the current law text. `tools/forms/verify_against_db.py` checks that every database column is described.