SuperAPI AI Directory

gst-einvoice-mcp

Convert Indian GST invoices (PDF or scanned) into INV-01 e-invoice JSON, with every value checked against the document plus GSTIN and arithmetic validation.

Open website

About this tool

Purpose

gst-einvoice-mcp converts Indian GST tax invoices into the government-required INV-01 JSON payload and clearly states what it cannot read. It generates a submittable payload, not a filed invoice—it does not include the IRN (Invoice Reference Number). The IRN must be issued by the government's Invoice Registration Portal after the payload is submitted, and this repository does not communicate with the IRP.

Main capabilities

  • Provides three tools as an MCP server, enabling agents to parse documents, validate GSTINs, or revalidate payloads already held.
  • Combines OCR, deterministic extraction, and a document-based LLM stage.
  • Core rule: the model may structure text, but must never fabricate values. This rule is enforced both through prompts and by tracing each value back to the document text. Values without a document source are replaced with null and reported; if the field is required in INV-01, no payload is generated.
  • All information about its own work (how each page was read, the source of each field, and uncertainties) is placed in extraction_meta and not in the payload, so the payload strictly conforms to the specification (the government API rejects unknown keys).
  • parse_invoice has three normal outcomes: a payload with warnings (usable, but the warnings indicate low OCR confidence fields, fields assigned by position rather than label, and fields derived rather than printed); no payload with missing_fields populated (required fields could not be read and were not filled in by fabrication); no payload with refusals populated (export, SEZ, and foreign exchange invoices are refused by design, with an explanation of what was detected and what to do instead).
  • The warnings block lists what the tool cannot corroborate, helping to locate the problem; no output from the four arithmetic validators means they passed.
  • On invoices whose template omits columns, you will see the pipeline state that a field is derived rather than read, with field_provenance recorded as "source": "derived". Five rules can trigger derivation: set an inapplicable tax to zero based on the two state codes; populate the line total from the taxable value and discount, or vice versa (exact inverses of each other, and both will not appear on the same line); for a single-line invoice where only the total is printed in the footer, populate the line total from the INV-01 item identity; populate a document total omitted by the model from the corresponding line value (single-line invoices only). The latter two rules trigger only when the result reconciles with the printed ValDtls.TotInvVal, and derived values are not derived again across line/total boundaries. For multi-line invoices missing TotItemVal or the document total is still reported missing and no payload is generated.
  • extraction_meta.field_provenance records the stage that produced each field in the payload (45 for the example invoice), and scanned pages also record OCR confidence (0.86 to 0.96 under clean 300 dpi rendering, taking the lowest confidence of each word in the field).

How to use

Requires Python 3.11 or higher, plus the system dependency Tesseract OCR. Tesseract does not need to be in PATH: the OCR module first checks PATH, then the standard Windows installation location, and if both fail it raises an actionable error naming both.

The default model is openai/gpt-oss-120b, which works without configuration. In deployment you should still set GST_MCP_MODEL, because a hardcoded model identifier silently fails after the provider deprecates it, manifesting as an HTTP 404 resembling a key error. Pin a model you have access to, and check it against Groq's deprecation notices.

MCP client configuration: pip install puts the gst-einvoice-mcp command into PATH, and the client only needs to name it. If running from a clone rather than an installation, point command to the interpreter in the virtual environment and call the module directly; on Windows the interpreter path ends with .venv\Scripts\python.exe.

Note this when testing local changes: the MCP server runs the version installed in site-packages, not the working tree. Editing repository files does not change server behavior, and there is no error message. You need to reinstall after every change, or point the MCP client's command to the repository's own virtual environment. After changing code you need to restart the MCP server, because a running server holds the modules imported at startup.

Applicable scenarios

Suitable for accounting, finance, or compliance workflows that need to convert Indian GST tax invoices into INV-01 JSON payloads, especially scenarios that automate processing of PDF or scanned invoices through MCP agents.

Limitations

  • Does not generate an IRN, and does not communicate with the IRP.
  • Export, SEZ, and foreign exchange invoices are rejected by design.
  • Multi-line invoices do not generate a payload when TotItemVal or the document total is missing.
  • Before use you should read LIMITATIONS.md, which specifically explainswhat the tool cannot substantiate and the cost of that.
  • Depends on PyMuPDF (AGPL-3.0); if distributed as part of a closed-source product, check the license first.
  • The test suite contains 1644 tests across ten modules, and warnings are treated as errors; the LLM stage accepts an injected client, so the entire suite runs without an API key or network. The suite passes on 3.11 and 3.13, with 3.11 as the minimum version.