Skip to main content

anafpy — typed Python clients for Romania's ANAF tax web services

CI Coverage PyPI version Downloads Python versions Docs License

anafpy

Typed Python clients for Romania's ANAF tax-authority web services — e-Factura (electronic invoicing), e-Transport (goods transport), the SPV mailbox (certificate-authenticated, read-only), tax declarations (declarații — local authoring, validation, qualified signing, filing), and the public no-auth registries (VAT/taxpayer lookups, financial statements), plus BNR's exchange rates for the lei figures those filings need from foreign-currency documents — and a local MCP server that puts all of it inside Claude.

anafpy is a thin transport client — no persistence, no accounting logic. Invoices file either as the XML your invoicing software produced (the strongly recommended path — anafpy never re-composes it) or composed from plain business fields by the built-in CIUS-RO authoring models. Either way, ANAF's SPV is not invoice storage (it purges filed messages after ~60 days) — the durable record stays on your side.

Status: beta (0.x), on PyPI as anafpy; the design rationale lives in DESIGN.md. Requires Python 3.12+; built on httpx2 and Pydantic v2.

Documentation: anafpy.readthedocs.io — the end-user setup walkthrough, the library guides, and the API reference.

Use it with Claude

With the MCP server connected, an accountant can ask Claude to:

  • Verify business partners — VAT status, e-Factura enrollment, financial statements — with no login at all.
  • Work the e-Factura inbox: list messages, save signed ZIPs and rendered PDFs to disk in batch, and file invoices — from your software's XML or composed from plain fields.
  • Declare goods transport in e-Transport and get the UIT code — from an email, a PDF invoice, a CMR — then correct, delete, confirm, or change the vehicle. The UIT comes back as a driver card and an A4 detail document (PDF).
  • Read the SPV mailbox and pull official reports (fiscal vector, outstanding obligations, filing history, income certificates...).
  • Prepare, validate, sign, and file tax declarations — validated by ANAF's own DUKIntegrator, signed with your qualified certificate.

Every ANAF filing is two-step gated: Claude shows a preview and nothing is submitted until you explicitly confirm. The server runs locally on your machine; artifacts land on your own disk.

Getting started is one click: every release attaches self-contained Claude Desktop extensions — pick the one for your machine (anafpy-darwin-arm64.mcpb for Apple silicon, anafpy-darwin-x64.mcpb for Intel Macs, anafpy-win32-x64.mcpb for Windows), drag it into Claude Desktop's Settings → Extensions, and fill in three settings. The bundle carries its own Python — no terminal, nothing else to install. The setup walkthrough (also in Romanian) covers the ANAF side — registering your OAuth application, the certificate login — and the full tour of what you can do shows the rest.

Install

Using it with Claude? The Desktop extension above is the install — no Python, no pip, no venv on the machine.

As a Python library:

pip install anafpy               # or: uv add anafpy
pip install 'anafpy[mcp]'        # with the MCP server
pip install 'anafpy[declaratii]' # with declaration signing (pyHanko)
pip install 'anafpy[cards]'      # with the UIT card / detail PDFs

The anafpy CLI and a standalone anafpy-mcp server (for MCP clients other than the extension) install as a uv tool, outside any project environment: uv tool install "anafpy[mcp,declaratii,cards]" — the setup walkthrough's terminal route.

Use it as a Python library

ANAF uses OAuth2 gated by a qualified digital certificate; a one-time anafpy auth login opens the browser for the certificate step, then tokens refresh headlessly for ~a year from the OS credential store — the authentication guide has the details. From there the clients are async context managers:

from anafpy.auth import KeyringTokenStore, TokenProvider
from anafpy.efactura import EFacturaClient

provider = TokenProvider(
    client_id="<ID>",
    client_secret="<SECRET>",
    store=KeyringTokenStore(),  # OS credential store (the default backend)
)

async with EFacturaClient(provider) as efactura:
    result = await efactura.upload(invoice_xml, cif="RO12345678")
    status = await efactura.get_status(result.upload_id)
    # or, in one call: status = await efactura.upload_and_wait(invoice_xml, cif=...)

Discrete methods make a single call (no transport retry). HTTP/auth problems raise AnafError subclasses; business outcomes (a nok rejection, BR-RO findings) come back as typed values, not exceptions.

The clients at a glance page inventories every client; the worked examples live in the per-service guides — e-Factura, invoice authoring, e-Transport, public services, exchange rates, SPV, declarations, and the error model.

MCP server

The anafpy[mcp] extra ships a local stdio MCP server wrapping the clients. The surface is read-first: the public lookups and efactura_validate need no credentials at all, reads need the one-time login, and every filing goes through the two-step prepare→submit confirmation gate. The compiled ANAF reference is served as resources and the workflow playbooks as prompts. The Desktop extension is this same server, packaged; any other MCP client registers a uv tool-installed anafpy-mcp directly — e.g. with Claude Code:

claude mcp add anafpy \
  -e ANAFPY_CLIENT_ID=... -e ANAFPY_CLIENT_SECRET=... -e ANAFPY_CIF=... \
  -- anafpy-mcp

The tools overview and workflow skills document the full surface. The server is best-effort: configuring it — including registering your own OAuth application on ANAF's portal — is your responsibility, and the setup walkthrough covers every step.

Contributing

Dev setup, the four gates, live smokes, and the generated-code rules are in CONTRIBUTING.md; repository conventions live in CLAUDE.md.

Privacy Policy

anafpy runs entirely on your own computer and collects nothing — no telemetry, no analytics, no author-operated server. Your data moves only between your machine and ANAF (BNR's public rate feed and your certificate issuer's public certificate download receive none of it); tokens and downloaded documents are stored locally, and your certificate's private key is never touched. When used through an AI assistant, tool results become part of that conversation under your AI provider's own policy. The full policy: anafpy.readthedocs.io/en/latest/privacy/.

License

Apache-2.0. Independent / unofficial — not affiliated with ANAF.

anafpy is free to use and provided as-is, with no warranty: it moves documents to and from ANAF, it does not give tax advice, and filing outcomes are your responsibility. The MCP server is best-effort — configuring it, provisioning your own OAuth application on ANAF's portal, and holding the qualified certificate are up to you (the setup walkthrough covers all of it).

Metadata

Release files for anafpy 0.13.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anafpy 0.13.5
File Size Uploaded Provenance Actions
anafpy-0.13.5.tar.gz 6.3 MB With provenance Details for anafpy-0.13.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anafpy 0.13.5
File Interpreter ABI Platform Actions
anafpy-0.13.5-py3-none-any.whl Python 3 none any Details for anafpy-0.13.5-py3-none-any.whl

Total release size: 7.3 MB

Release files / anafpy-0.13.5.tar.gz

Download URL anafpy-0.13.5.tar.gz
Size 6.3 MB
Tags Source
SHA-256 checksum
How to use checksums
349d448cbe3cffd47cb06d222876bc9d6fd225dd2496ac85f44e875729685904
BLAKE2b-256 checksum
How to use checksums
a0b92135ec4d467432beaa3ba1c33609e615bc2b1e5484ecadf9b9757df6baf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / anafpy-0.13.5-py3-none-any.whl

Download URL anafpy-0.13.5-py3-none-any.whl
Size 990.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb9c23bbe95e98f581e0a00ad8a2f0eabc0c8d520b2e9614e798de4a361a3f37
BLAKE2b-256 checksum
How to use checksums
ed14969f7a25bf7f476bfb4743ed8b363e38ac9bfb2b6a6cba5ec85a82fda0e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for anafpy 0.13.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for anafpy-0.13.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.13.5 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page