Skip to main content
Glama
README.md
# vies-vat-mcp

A [Model Context Protocol](https://modelcontextprotocol.io) server for [VIES](https://ec.europa.eu/taxation_customs/vies/), the European Commission's VAT number validation service, which queries each member state's VAT register. It needs no API key and is read-only.

It is aimed at invoicing, customer onboarding and marketplace checks. The tools are shaped around those jobs rather than one tool per endpoint: bulk validation with malformed numbers caught locally, a clear split between "invalid" and "the member state's service is down", an optional consultation number for your records, and company name and address matching against the register.

## Setup

Requires Python 3.12+ and [uv](https://docs.astral.sh/uv/).

```bash
git clone https://github.com/Ankur1911/vies-vat-mcp && cd vies-vat-mcp
uv sync
uv run vies-vat-mcp          # stdio transport
```

Add it to any MCP client that launches stdio servers:

```json
{
  "mcpServers": {
    "vies-vat": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/vies-vat-mcp", "vies-vat-mcp"]
    }
  }
}
```

For HTTP instead of stdio: `MCP_TRANSPORT=streamable-http MCP_HOST=127.0.0.1 MCP_PORT=8000 uv run vies-vat-mcp`.

## Tools

All tools are read-only.

| Tool | What it returns |
|---|---|
| `validate_vat` | 1 to 25 VAT numbers in one call, in any spacing or punctuation (`DE 169.838.187`). Each result is `valid` (with the registered name and address when the member state publishes them), `invalid`, `unavailable` (the member state's service is down or busy, so VIES cannot answer; not a negative result), `malformed` (wrong prefix or shape, caught locally with no request) or `error`. Duplicates are checked once; at most 3 requests run at a time. |
| `verify_vat_with_proof` | One number checked through the POST endpoint. Give your own EU VAT number as `requester_vat_number` to receive VIES's consultation number; give a company name, street, postal code, city or legal form to get match / no_match per field plus the closest register values. |
| `check_vat_format` | Offline format check against each country's published pattern, with no request and no checksum. With no arguments it lists the expected format for every supported country. |
| `vies_status` | Whether VIES and each member state's service is online. Use it when `validate_vat` reports `unavailable`. |

Country prefixes follow VIES: Greece is `EL` (`GR` is accepted and converted) and Northern Ireland is `XI`.

## Configuration

All optional environment variables:

| Variable | Default | Meaning |
|---|---|---|
| `VIES_BASE_URL` | `https://ec.europa.eu/taxation_customs/vies/rest-api` | API root (for a proxy or test double) |
| `VIES_TIMEOUT` | `30` | Request timeout in seconds |
| `VIES_RETRIES` | `2` | Retries on HTTP 429, 502, 503, 504, timeouts and VIES busy/unavailable answers |
| `VIES_MAX_CHARS` | `20000` | Responses longer than this are cut with a notice |
| `MCP_TRANSPORT` | `stdio` | `stdio` or `streamable-http` |

## Limits

- Covers EU member states and Northern Ireland (`XI`). Great Britain VAT numbers are not in VIES.
- VIES confirms that a number is registered. It does not give tax advice, and some member states (for example Germany and Spain) return `valid` without a name or address, so name matching is only useful where the register exposes those details.
- Member-state services go offline regularly. Those numbers come back as `unavailable`; retry later or check `vies_status`.
- The format check is a pattern check only; it does not verify check digits.
- The consultation number is only issued when the requester number you supply is itself a valid EU VAT number. Whether it counts as proof for a given tax authority is a question for that authority.
- The public service has usage limits and may block an address that sends too many requests. Bulk calls are capped at 25 numbers.

## Development

```bash
uv sync
uv run pytest
```

Tests mock all HTTP traffic with `respx`; no network access is needed. The mocked response shapes were taken from live VIES answers (Ireland valid with name and address, Germany valid without details, France and the Netherlands invalid, an unknown country code, and the status endpoint). The trader-matching endpoint (`POST /check-vat-number`) is covered by mocks only.

## Licence

MIT. Author: Ankur Kapuriya. Not affiliated with or endorsed by the European Commission. VIES data comes from the member states' registers; check the VIES terms before redistributing results.