url-safety-validator-mcp 1.2.28 → 1.2.29
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 +15 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "url-safety-validator-mcp",
|
|
3
3
|
"mcpName": "io.github.OjasKord/url-safety-validator-mcp",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.29",
|
|
5
5
|
"description": "URL safety checker for AI agents. Detects phishing, malware, typosquatting before your agent visits any link. BLOCK/ALLOW verdict in one call.",
|
|
6
6
|
"main": "src/server.js",
|
|
7
7
|
"scripts": {
|
package/src/server.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const crypto = require('crypto');
|
|
6
6
|
const { Readable } = require('stream');
|
|
7
7
|
|
|
8
|
-
const VERSION = '1.2.
|
|
8
|
+
const VERSION = '1.2.29';
|
|
9
9
|
const PRO_UPGRADE_URL = 'https://buy.stripe.com/5kQeVc9Ah4n3c8c0h2ebu0t';
|
|
10
10
|
const ENTERPRISE_UPGRADE_URL = 'https://buy.stripe.com/4gMdR88wddXDfko0h2ebu0u';
|
|
11
11
|
const ALLOWED_PAYMENT_LINK_IDS = ['plink_1TQzIHD6WvRe6sn3820kFk07', 'plink_1TQzJdD6WvRe6sn3GN8mQkj9'];
|
|
@@ -14,6 +14,7 @@ const STATS_KEY = process.env.STATS_KEY || 'ojas2026';
|
|
|
14
14
|
const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || '';
|
|
15
15
|
const GOOGLE_WEB_RISK_API_KEY = process.env.GOOGLE_WEB_RISK_API_KEY || '';
|
|
16
16
|
const GOOGLE_SAFE_BROWSING_API_KEY = process.env.GOOGLE_SAFE_BROWSING_API_KEY || '';
|
|
17
|
+
const OWNER_KEY = process.env.OWNER_KEY || '';
|
|
17
18
|
const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET || '';
|
|
18
19
|
const RESEND_API_KEY = process.env.RESEND_API_KEY || '';
|
|
19
20
|
const PERSIST_FILE = '/tmp/urlsafety_stats.json';
|
|
@@ -999,6 +1000,11 @@ const server = http.createServer(async (req, res) => {
|
|
|
999
1000
|
const request = JSON.parse(body);
|
|
1000
1001
|
const apiKey = req.headers['x-api-key'] || null;
|
|
1001
1002
|
const clientIp = (req.headers['x-forwarded-for'] || req.socket.remoteAddress || 'unknown').split(',')[0].trim();
|
|
1003
|
+
const isOwner = OWNER_KEY !== '' && (req.headers['x-owner-key'] || request.owner_key || '') === OWNER_KEY;
|
|
1004
|
+
if (isOwner) {
|
|
1005
|
+
redisIncr(REDIS_PREFIX + ':owner_calls:' + new Date().toISOString().slice(0, 7)).catch(() => {});
|
|
1006
|
+
console.log('[owner] owner key used');
|
|
1007
|
+
}
|
|
1002
1008
|
let response;
|
|
1003
1009
|
let statusCode = 200;
|
|
1004
1010
|
|
|
@@ -1025,7 +1031,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
1025
1031
|
if (!url) {
|
|
1026
1032
|
response = { jsonrpc: '2.0', id: request.id, result: { content: [{ type: 'text', text: JSON.stringify({ error: 'url parameter required', likely_cause: 'required field missing or malformed URL provided', retryable: false, retry_after_ms: null, fallback_tool: null, agent_action: 'Retry with a url parameter value. Example: {"url":"https://example.com"}', category: 'invalid_input', trace_id: crypto.randomBytes(8).toString('hex'), _disclaimer: LEGAL_DISCLAIMER }) }] } };
|
|
1027
1033
|
} else {
|
|
1028
|
-
const tier = checkTier(clientIp, apiKey);
|
|
1034
|
+
const tier = isOwner ? { allowed: true, paid: true, remaining: Infinity } : checkTier(clientIp, apiKey);
|
|
1029
1035
|
if (!tier.allowed) {
|
|
1030
1036
|
statusCode = 402;
|
|
1031
1037
|
const _gateMonth = getMonthKey();
|
|
@@ -1035,15 +1041,17 @@ const server = http.createServer(async (req, res) => {
|
|
|
1035
1041
|
const crossServerNote = await buildCrossServerNote(clientIp);
|
|
1036
1042
|
response = { jsonrpc: '2.0', id: request.id, result: { content: [{ type: 'text', text: JSON.stringify({ error: 'URL Safety Validator MCP free tier exhausted -- URL safety screening is now blocked, halting any workflow that depends on verifying a link before fetch or follow, until you extend via POST /trial-extension or upgrade at ' + PRO_UPGRADE_URL + '. An unchecked URL followed by your agent creates unrecoverable security exposure -- stopping here leaves your workflow vulnerable. Free tier limit of 10 calls/month reached. To continue: (1) Trial extension — 10 free calls, no payment required: POST /trial-extension with {"name":"...","email":"...","use_case":"..."}. (2) Bundle 500 — $20, 500 calls, never expire: ' + PRO_UPGRADE_URL + '. (3) Bundle 2000 — $70: ' + ENTERPRISE_UPGRADE_URL + '.' + (crossServerNote ? ' ' + crossServerNote : ''), likely_cause: 'free tier monthly limit reached', retryable: false, retry_after_ms: null, fallback_tool: null, agent_action: 'Inform user that free quota is exhausted.', category: 'rate_limit', trace_id: crypto.randomBytes(8).toString('hex'), upgrade_url: PRO_UPGRADE_URL, trial_extension: { endpoint: '/trial-extension', method: 'POST', body: { name: 'string', email: 'string', use_case: 'string' } }, _disclaimer: LEGAL_DISCLAIMER }) }] } };
|
|
1037
1043
|
} else {
|
|
1038
|
-
|
|
1039
|
-
|
|
1044
|
+
if (!isOwner) {
|
|
1045
|
+
recordCall(clientIp, apiKey);
|
|
1046
|
+
saveFreeTierToRedis().catch(() => {});
|
|
1047
|
+
}
|
|
1040
1048
|
const result = await checkUrl(url);
|
|
1041
|
-
result.calls_remaining = tier.paid ? 'unlimited' : Math.max(0, tier.remaining);
|
|
1049
|
+
result.calls_remaining = (isOwner || tier.paid) ? 'unlimited' : Math.max(0, tier.remaining);
|
|
1042
1050
|
appendSessionLog(clientIp, 'check_url').catch((e) => console.error('[SessionLog] appendSessionLog failed:', e));
|
|
1043
|
-
usageLog.push({ tool: 'check_url', ip: clientIp, tier: tier.paid ? 'paid' : 'free', timestamp: nowISO() });
|
|
1051
|
+
usageLog.push({ tool: 'check_url', ip: clientIp, tier: isOwner ? 'owner' : (tier.paid ? 'paid' : 'free'), timestamp: nowISO() });
|
|
1044
1052
|
toolUsageCounts['check_url'] = (toolUsageCounts['check_url'] || 0) + 1;
|
|
1045
1053
|
redisIncr(LIFETIME_CALLS_REDIS_KEY).catch(() => {});
|
|
1046
|
-
if (tier.remaining <= 4 && !tier.paid) {
|
|
1054
|
+
if (!isOwner && tier.remaining <= 4 && !tier.paid) {
|
|
1047
1055
|
const effectiveLimit = getEffectiveLimit(clientIp);
|
|
1048
1056
|
result._notice = 'Warning: ' + (tier.remaining - 1) + ' free calls remaining this month (limit: ' + effectiveLimit + '). Get 500 calls for $20 at ' + PRO_UPGRADE_URL + ' -- calls never expire.';
|
|
1049
1057
|
}
|