Open Source · AI Published

Mexican Tax MCP Server

TypeScript MCP server with 8 read-only tools to validate Mexican RFC, CURP, CLABE and NSS, read CFDI 4.0 invoices and check their SAT status. No API keys, no PAC.

Role
Design & Development
Year
2026
Published
September 11, 2026
Cover of mx-fiscal-mcp-server with a CFDI 4.0 invoice, a SAT «Vigente» seal and RFC, CURP, CLABE and NSS validators on a dark background.

mx-fiscal-mcp-server is a TypeScript MCP (Model Context Protocol) server that gives an AI agent —like Claude— the Mexican tax and banking capabilities almost everyone ends up reimplementing wrong: validating RFC, CURP, CLABE and NSS with their real check digits, reading a CFDI 4.0 invoice, asking the SAT whether it is still live and looking up the SAT’s code tables. No API keys, no CSD certificate and no PAC contract.

Nothing to clone: claude mcp add mx-fiscal -- npx -y mx-fiscal-mcp-server

The read half

Mexican electronic invoicing has two halves. Building and stamping a CFDI needs a digital-seal certificate and a PAC, and that half already has tooling. Reading needs nothing: the check-digit algorithms are public, so are the catalogues, and the SAT’s status service —the one behind the QR code on every printed invoice— is public and unauthenticated. This server is that half, done carefully.

It is the next step in a thread of work on this site: the Mexican ID validator, the CFDI viewer and the test data generator. The arithmetic lives in the mx-identifiers library on npm, and the CFDI reader is the same one the web tool runs.

Features

  • 8 tools with typed output: validate_rfc, validate_curp, validate_clabe, validate_nss, generate_test_data, parse_cfdi, cfdi_status and sat_catalog_lookup. Each declares an inputSchema and outputSchema (Zod 4) and returns SDK-validated structuredContent alongside readable markdown.
  • Details a regex misses: XAXX010101000 does not satisfy its own check digit (the SAT assigned it by decree), the CLABE reduces each product modulo 10 before summing, CURP state keys are RENAPO’s own rather than INEGI’s, and the CURP’s 17th character encodes the century.
  • parse_cfdi: turns the XML into JSON with every catalogue code labelled, validates both RFCs and checks that the totals add up, local taxes included.
  • cfdi_status: queries the SAT’s ConsultaCFDIService and explains Estado, EsCancelable, EstatusCancelación and the EFOS check in plain words. Fail-soft: when the SAT does not answer it returns available: false with the reason, never “invalid invoice”.
  • Honest output: structurally valid is not registered, and test data is generated from common names, so the server warns that a value can coincide with a real person’s by chance.
  • Two transports: stdio for local clients and stateless Streamable HTTP for self-hosting, safe by default (loopback bind, Host and Origin validation, optional Bearer token), with a Dockerfile that runs as an unprivileged user.
  • Untrusted XML is bounded: a DOCTYPE is refused before parsing, and size and element-count caps apply.
  • Tested and published: 51 deterministic unit tests, a smoke test that calls all 8 tools on both protocol eras, CI on Node 20, 22 and 24 that also boots the package through npx and the Docker image, and published to npm and the official MCP Registry.

Tech stack

  • TypeScript, strict
  • MCP SDK v2 (@modelcontextprotocol/server): serves the 2026-07-28 revision and 2025-era clients from one factory
  • Zod 4 for input and output validation
  • @xmldom/xmldom for the CFDI reader
  • mx-identifiers for the check digits
  • Express 5 for the stateless HTTP transport
  • Docker for self-hosted deployment

Repository

View on GitHub → · Package on npm →

Goal

To fill a gap that was checked before building it, in September 2026: no MCP server read or validated Mexican tax data. An agent that has to review an invoice or seed a database with valid RFCs no longer depends on the model remembering an algorithm correctly, but on tools tested against the SAT’s, Banxico’s and RENAPO’s public vectors.

07 / Contact

Did any of this help? If your company needs it built, let's talk.

Fill out the form and I'll reply within 24 hours. You can also email me directly: