Skip to main content
Glama
junter1989k-ai

Mexico Invoice MCP

README.md
# Mexico Invoice MCP 🇲🇽 — How can my AI agent issue a CFDI factura electrónica in Mexico?

<!-- install-cta -->
## Use it in 60 seconds

Paste this into your MCP client config (Claude Desktop, Cursor, Windsurf, or any MCP-capable agent):

```json
{
  "mcpServers": {
    "mexico-invoice": {
      "type": "http",
      "url": "https://inv-mx.wishpool.app/mcp"
    }
  }
}
```

Nothing to install. Credentials, when you need them, travel as HTTP headers on each request and are never stored — see the [threat model](https://mcp.wishpool.app/trust).

### Or run it yourself

Would you rather not send production credentials to a server you do not control? Deploy this identical code to your own account and point your agent at your own URL:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/junter1989k-ai/mexico-invoice-mcp)

```bash
git clone https://github.com/junter1989k-ai/mexico-invoice-mcp && cd mexico-invoice-mcp && npx vercel --prod
```

MIT-licensed. Self-hosting removes us from the picture entirely, at no cost and with no loss of function.

---

Remote MCP server that lets any AI agent issue **Mexico CFDI 4.0 electronic invoices** (factura electrónica, stamped/timbrada through a SAT-certified PAC) via **two interchangeable PACs behind one tool set — [Facturapi](https://facturapi.io) and [Facturama](https://facturama.mx)**. Stateless, bring-your-own credentials, never stores anything. (One PAC going down, changing its API, or raising prices no longer breaks your invoicing — send the other PAC's credentials and keep issuing.)

**Live endpoint:** `https://inv-mx.wishpool.app/mcp` · Registry: `app.wishpool/mexico-invoice-mcp`

## Quick start

```json
{
  "mcpServers": {
    "mexico-invoice": {
      "type": "http",
      "url": "https://inv-mx.wishpool.app/mcp",
      "headers": { "x-facturapi-key": "sk_test_..." }
    }
  }
}
```

Free `sk_test_` keys from [facturapi.io](https://facturapi.io) never reach SAT. Your CSD certificate stays in your own Facturapi account — this server never sees it.

**Or use Facturama** (API-Web) instead — send these headers and requests route to Facturama automatically:

```json
"headers": {
  "x-facturama-user": "your_facturama_user",
  "x-facturama-password": "your_facturama_password",
  "x-facturama-expedition-place": "01000",
  "x-facturama-sandbox": "true"
}
```

`x-facturama-expedition-place` is your Facturama branch-office 5-digit ZIP (the issuer ZIP, which Facturama requires). `x-facturama-sandbox: true` targets the no-fiscal-effect sandbox; drop it for production. If you send both PACs' credentials, Facturapi wins unless you add `x-invoice-provider: facturama`. Your CSD certificate stays in your own Facturama account (API-Web) — this server never sees it. Facturama's multi-emisor mode (self-managed certificates) is intentionally not supported: it would require handling certificates, which this pure-forwarding layer avoids.

## Tools

| Tool | What it does |
|---|---|
| `create_invoice` | Stamp a CFDI 4.0 — customer RFC + zip + line items in, `uuid` (SAT folio fiscal) out. SAT catalog defaults baked in (`product_key 01010101`, `payment_form 03`, `use G03`). |
| `query_invoice` | Status check: `VALID` (stamped) or `CANCELED`; includes SAT `verification_url`. |
| `cancel_invoice` | Void at SAT with the required motive code (`01`–`04`, default `02`). |
| `send_invoice` | Email the stamped PDF + XML to the buyer via the issuing PAC. |

Owner policy guardrails ride optional headers (`x-agentpay-max-amount`, `x-agentpay-approval-above`, `x-agentpay-allowed-tools`) — set by the human owner in client config; the agent cannot relax them.

## Develop

```bash
node test/serve.js   # local server on :3226
node test/e2e.js     # protocol + validation + fake-key live probes
```

## Safety

Pure stateless translation layer. The SAT/PAC certification burden sits with the PAC (Facturapi or Facturama); credentials travel per-request in headers, nothing is stored. [Privacy policy](https://inv-mx.wishpool.app/privacy).

## Sister servers

Local payments in 81 countries, one family: [mcp.wishpool.app](https://mcp.wishpool.app) · Taiwan e-invoice 電子發票 included. More invoice countries coming: Brazil NF-e · Chile DTE · Peru CPE · India GST · Poland KSeF · Romania e-Factura · Italy SdI.

MIT licensed.