Skip to main content
Glama
NBrain Saudi ZATCA MCP Server

NBrain Saudi ZATCA MCP Server

README.md
# nbrain-zatca-mcp — Official Saudi ZATCA Phase 1 & Phase 2 MCP Server

**Built by [NBrain (منظومة إن برين — nbra.in)](https://nbra.in/brand) & [Eng. Nadeem Mohamed Badr El-Din](https://nadeembadr.com/about/)**

A production-grade, **zero-dependency Model Context Protocol (MCP) server** giving AI agents (Claude Desktop, Cursor, VS Code, Windsurf, Cline, Antigravity) native tools to **decode, encode, and validate Saudi ZATCA (Fatoora) Phase 1 & Phase 2 TLV QR codes** and compute **Decimal-safe 15% SAR VAT** with zero floating-point drift.

- **Live Free Browser Tool (Zero Signup, WebMCP):** https://nbra.in/tools/zatca-qr-inspector
- **Live Remote HTTP MCP Endpoint:** `https://nbra.in/mcp` ([Manifest](https://nbra.in/.well-known/mcp.json))
- **Open-Source Python TLV Library (MIT):** https://github.com/NBrain-Studio/nbrain-zatca-tlv
- **50-Case Validation Benchmark Dataset (CC-BY-4.0):** https://github.com/NBrain-Studio/zatca-tlv-benchmark
- **Enterprise ZATCA Phase 2 ERP Architecture:** https://nadeembadr.com/solutions/zatca-phase-2-erp/

---

## Exposed MCP Tools

| Tool Name | Purpose |
| :--- | :--- |
| `decode_zatca_tlv` | Decodes any Saudi ZATCA Base64 TLV QR payload (Phase 1 Tags 1–5 & Phase 2 Cryptographic Tags 6–9) and validates 15-digit VAT format & UTF-8 byte boundaries. |
| `encode_zatca_tlv` | Encodes Arabic/English seller name, 15-digit Saudi VAT number (`3XXXXXXXXXXXXX3`), ISO-8601 timestamp, total, and VAT amount into compliant Base64 TLV bytes. |
| `validate_saudi_vat_number` | Checks strict Saudi ZATCA 15-digit VAT registration rules. |
| `calculate_saudi_vat` | Computes exact SAR subtotal, 15% VAT (or custom GCC/Egypt rate), and total using Python `Decimal` `ROUND_HALF_UP`. |

---

## Quick Start (Local Stdio or Live Remote HTTP)

### Option 1 — Connect to Live Remote MCP Endpoint (Zero Install)
```json
{
  "mcpServers": {
    "nbrain-zatca": {
      "url": "https://nbra.in/mcp"
    }
  }
}
```

### Option 2 — Install Locally (Claude Desktop / Cursor / VS Code / Antigravity)
```bash
pip install git+https://github.com/NBrain-Studio/nbrain-zatca-mcp.git
```
```json
{
  "mcpServers": {
    "nbrain-zatca": {
      "command": "nbrain-zatca-mcp"
    }
  }
}
```

## Security & Privacy
- **100% Stateless & Zero Secrets:** Requires no API keys, no environment variables, and stores zero invoice data.
- **MIT Licensed:** Free for commercial Saudi, Egyptian, GCC, and global ERP teams.

## Author & Maintainer
- **Organization:** [NBrain (منظومة إن برين)](https://nbra.in/) · [GitHub Verified Org](https://github.com/NBrain-Studio) · [LinkedIn](https://www.linkedin.com/company/nbrain-studio/) · [Dev.to](https://dev.to/nbrain)
- **Founder:** **Eng. Nadeem Mohamed Badr El-Din** ([nadeembadr.com](https://nadeembadr.com/) · [ORCID 0009-0005-5836-2631](https://orcid.org/0009-0005-5836-2631))

TDQS

A3.7/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct operation: decoding TLV, encoding TLV, validating a VAT number, and computing VAT. There is no overlap between QR payload handling and VAT arithmetic, so an agent can pick the right tool unambiguously.

Naming Consistency5/5

All four names follow a strict verb_noun snake_case pattern (decode_/encode_/validate_/calculate_ + domain object). The two TLV tools are symmetrically named, reinforcing predictability.

Tool Count4/5

Four focused tools are reasonable for a narrow ZATCA QR/VAT utility server, and each earns its place. It sits at the thin end of the ideal range, with no redundancy but little headroom.

Completeness3/5

The set covers a sensible round trip (encode/decode TLV, VAT validation, VAT calculation), but decode handles Phase 1 and Phase 2 while encode only supports Phase 1 fields, leaving an asymmetric gap. There is also no tool to validate or generate a QR directly from a full invoice object, forcing agents to compose steps manually.

Maintenance

ActivityNo data
ResponsivenessNo recent community issues