vat-validator-mcp 2.0.12 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server.js +17 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vat-validator-mcp",
|
|
3
3
|
"mcpName": "io.github.OjasKord/vat-validator-mcp",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.14",
|
|
5
5
|
"description": "VAT number validator for AI agents. EU VIES, UK HMRC, AU ABR — auto-detects jurisdiction. Fraud risk scoring and invoice name cross-check in one call.",
|
|
6
6
|
"main": "src/server.js",
|
|
7
7
|
"scripts": {
|
package/src/server.js
CHANGED
|
@@ -7,7 +7,7 @@ const Stripe = require('stripe');
|
|
|
7
7
|
const stripe = Stripe(process.env.STRIPE_SECRET_KEY);
|
|
8
8
|
|
|
9
9
|
const PERSIST_FILE = '/tmp/vat_stats.json';
|
|
10
|
-
const VERSION = '2.0.
|
|
10
|
+
const VERSION = '2.0.14';
|
|
11
11
|
|
|
12
12
|
// Persistent device ID for HMRC fraud prevention headers (BATCH_PROCESS_DIRECT)
|
|
13
13
|
const DEVICE_ID_FILE = path.join(__dirname, '..', 'device-id.txt');
|
|
@@ -160,7 +160,13 @@ async function loadFreeTierFromRedis() {
|
|
|
160
160
|
|
|
161
161
|
async function saveFreeTierToRedis() {
|
|
162
162
|
try {
|
|
163
|
-
await
|
|
163
|
+
const existing = await redisGet(FREE_TIER_REDIS_KEY) || [];
|
|
164
|
+
const existingMap = new Map(existing);
|
|
165
|
+
for (const [key, value] of freeTierUsage.entries()) {
|
|
166
|
+
const existingCount = existingMap.get(key) || 0;
|
|
167
|
+
existingMap.set(key, Math.max(existingCount, value));
|
|
168
|
+
}
|
|
169
|
+
await redisSet(FREE_TIER_REDIS_KEY, Array.from(existingMap.entries()));
|
|
164
170
|
} catch(e) { console.error('[FreeTier] save failed:', e); }
|
|
165
171
|
}
|
|
166
172
|
|
|
@@ -788,8 +794,16 @@ const server = http.createServer(async (req, res) => {
|
|
|
788
794
|
if (req.headers['x-stats-key'] !== STATS_KEY) { res.writeHead(401, cors); res.end(JSON.stringify({ error: 'Unauthorized' })); return; }
|
|
789
795
|
const totalFreeCalls = Array.from(freeTierUsage.values()).reduce((a, b) => a + b, 0);
|
|
790
796
|
const freeUniqueIPs = new Set(Array.from(freeTierUsage.keys()).map(k => k.split(':')[0])).size;
|
|
797
|
+
const monthPrefix = new Date().toISOString().slice(0, 7);
|
|
798
|
+
const breakdown = {};
|
|
799
|
+
for (const [key, count] of freeTierUsage.entries()) {
|
|
800
|
+
if (key.includes(':' + monthPrefix)) {
|
|
801
|
+
const ip = key.split(':')[0];
|
|
802
|
+
breakdown[ip.slice(0, 10) + '...'] = count;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
791
805
|
res.writeHead(200, { ...cors, 'Content-Type': 'application/json' });
|
|
792
|
-
res.end(JSON.stringify({ free_tier_unique_ips: freeUniqueIPs, free_tier_total_calls: totalFreeCalls, paid_keys_issued: apiKeys.size, tool_usage: toolUsageCounts, recent_calls: usageLog.slice(-20).reverse(), trial_extensions_granted: trialExtensions.size }));
|
|
806
|
+
res.end(JSON.stringify({ free_tier_unique_ips: freeUniqueIPs, free_tier_total_calls: totalFreeCalls, paid_keys_issued: apiKeys.size, tool_usage: toolUsageCounts, recent_calls: usageLog.slice(-20).reverse(), trial_extensions_granted: trialExtensions.size, free_tier_breakdown: breakdown }));
|
|
793
807
|
return;
|
|
794
808
|
}
|
|
795
809
|
|