validate_vat_de
Validates German VAT identification numbers (USt-IdNr) by checking format and ISO 7064 checksum. Essential for processing invoices or validating suppliers in intra-EU transactions.
Instructions
Validates a German VAT identification number (Umsatzsteuer-Identifikationsnummer, USt-IdNr) — format 'DE' followed by 9 digits. Verifies the format and applies the official ISO 7064 MOD-11-10 checksum algorithm. Returns { valid: boolean, vat_number: string, country: 'DE' } or { valid: false, reason: string }. Use when processing German invoices, validating German suppliers for intra-EU transactions, or any B2B workflow involving German companies.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vat_number | Yes | German VAT number with or without spaces. Example: 'DE123456789' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| valid | Yes | ||
| vat_number | No | ||
| country | No | ||
| reason | No |
Implementation Reference
- index.js:320-339 (handler)The handler function for validate_vat_de tool. Applies the ISO 7064 MOD-11-10 checksum algorithm to validate German VAT numbers (USt-IdNr). Expects format 'DE' + 9 digits. Returns { valid, vat_number, country } or { valid: false, reason }.
// ── 14. Validate German VAT (USt-IdNr) ── server.registerTool("validate_vat_de", { description: "Validates a German VAT identification number (Umsatzsteuer-Identifikationsnummer, USt-IdNr) — format 'DE' followed by 9 digits. Verifies the format and applies the official ISO 7064 MOD-11-10 checksum algorithm. Returns { valid: boolean, vat_number: string, country: 'DE' } or { valid: false, reason: string }. Use when processing German invoices, validating German suppliers for intra-EU transactions, or any B2B workflow involving German companies.", inputSchema: { vat_number: z.string().describe("German VAT number with or without spaces. Example: 'DE123456789'") }, outputSchema: { valid: z.boolean(), vat_number: z.string().optional(), country: z.string().optional(), reason: z.string().optional() }, annotations: { title: "Validate German VAT Number", readOnlyHint: true, idempotentHint: true, openWorldHint: false } }, async ({ vat_number }) => { const clean = vat_number.replace(/\s/g, "").toUpperCase(); if (!/^DE\d{9}$/.test(clean)) return { content: [{ type: "text", text: JSON.stringify({ valid: false, reason: "German VAT must start with DE followed by exactly 9 digits. Example: DE123456789" }) }] }; const digits = clean.substring(2); let product = 10; for (let i = 0; i < 8; i++) { let sum = (parseInt(digits[i]) + product) % 10; if (sum === 0) sum = 10; product = (2 * sum) % 11; } const checkDigit = 11 - product === 10 ? 0 : 11 - product; const valid = checkDigit === parseInt(digits[8]); return { content: [{ type: "text", text: JSON.stringify({ valid, vat_number: clean, country: "DE" }) }] }; }); - index.js:321-326 (schema)Input and output schema definitions for validate_vat_de. Input expects 'vat_number' (string), output includes valid (boolean), vat_number (optional string), country (optional string), reason (optional string).
server.registerTool("validate_vat_de", { description: "Validates a German VAT identification number (Umsatzsteuer-Identifikationsnummer, USt-IdNr) — format 'DE' followed by 9 digits. Verifies the format and applies the official ISO 7064 MOD-11-10 checksum algorithm. Returns { valid: boolean, vat_number: string, country: 'DE' } or { valid: false, reason: string }. Use when processing German invoices, validating German suppliers for intra-EU transactions, or any B2B workflow involving German companies.", inputSchema: { vat_number: z.string().describe("German VAT number with or without spaces. Example: 'DE123456789'") }, outputSchema: { valid: z.boolean(), vat_number: z.string().optional(), country: z.string().optional(), reason: z.string().optional() }, annotations: { title: "Validate German VAT Number", readOnlyHint: true, idempotentHint: true, openWorldHint: false } }, async ({ vat_number }) => { - index.js:321-321 (registration)Registration of the validate_vat_de tool via server.registerTool, with description stating it validates German USt-IdNr using ISO 7064 MOD-11-10 checksum.
server.registerTool("validate_vat_de", {