@samuelduchaine/mcps
Version:
Model Context Protocol Secure (MCPS) - The security standard for MCP servers. Enterprise-grade security layer with A+ certification readiness.
143 lines (114 loc) ⢠3.94 kB
JavaScript
/**
* MCPS Licensing & Feature Protection
* Enterprise and Pro feature access control
*/
const crypto = require('crypto');
const os = require('os');
class McpsLicensing {
constructor() {
this.tiers = {
community: {
name: 'Community',
price: 'Free',
features: ['basic-security', 'self-signed-certs', 'basic-tests']
},
pro: {
name: 'Pro',
price: '$99/month',
features: ['enterprise-pki', 'advanced-monitoring', 'ai-threat-detection', 'compliance-reporting']
},
enterprise: {
name: 'Enterprise',
price: 'Contact Sales',
features: ['zero-trust', 'siem-integration', 'quantum-crypto', 'priority-support', '24x7-monitoring']
}
};
}
getCurrentTier() {
// Check for license file or environment variables
const licenseKey = process.env.MCPS_LICENSE_KEY || this.loadLicenseFile();
if (!licenseKey) {
return 'community';
}
return this.validateLicense(licenseKey);
}
loadLicenseFile() {
try {
const fs = require('fs');
const path = require('path');
const licenseFile = path.join(os.homedir(), '.mcps', 'license.key');
if (fs.existsSync(licenseFile)) {
return fs.readFileSync(licenseFile, 'utf8').trim();
}
} catch (error) {
// Ignore file read errors
}
return null;
}
validateLicense(licenseKey) {
// Simple license validation (production would use proper crypto)
if (licenseKey.startsWith('MCPS-PRO-')) {
return 'pro';
} else if (licenseKey.startsWith('MCPS-ENT-')) {
return 'enterprise';
}
return 'community';
}
hasFeature(feature) {
const currentTier = this.getCurrentTier();
return this.tiers[currentTier].features.includes(feature);
}
requireFeature(feature, featureName = feature) {
if (!this.hasFeature(feature)) {
const currentTier = this.getCurrentTier();
const availableIn = Object.keys(this.tiers).find(tier =>
this.tiers[tier].features.includes(feature)
);
throw new Error(`
š« MCPS ${featureName} - License Required
Current Tier: ${this.tiers[currentTier].name} (${this.tiers[currentTier].price})
Required Tier: ${this.tiers[availableIn].name} (${this.tiers[availableIn].price})
To unlock ${featureName}:
⢠Visit: https://mcps-security.com/pricing
⢠Email: sales@mcps-security.com
⢠Upgrade: mcps license upgrade
Enterprise features ensure production-grade security for mission-critical applications.
`);
}
}
showPricingInfo() {
console.log('\nš”ļø MCPS Security - Pricing Tiers\n');
Object.keys(this.tiers).forEach(tierKey => {
const tier = this.tiers[tierKey];
const current = this.getCurrentTier() === tierKey ? ' (CURRENT)' : '';
console.log(`š¦ ${tier.name}${current} - ${tier.price}`);
tier.features.forEach(feature => {
console.log(` ā ${feature.replace('-', ' ')}`);
});
console.log('');
});
console.log('š¼ Enterprise Volume Discounts Available');
console.log('š Academic & Non-Profit Licensing Available');
console.log('š§ Contact: sales@mcps-security.com\n');
}
generateTrialLicense() {
const expiryDate = new Date();
expiryDate.setDate(expiryDate.getDate() + 14); // 14-day trial
const trialKey = `MCPS-TRIAL-${crypto.randomBytes(8).toString('hex').toUpperCase()}-${expiryDate.getTime()}`;
console.log(`
š MCPS 14-Day Enterprise Trial Activated!
Trial License: ${trialKey}
To save this license:
echo "${trialKey}" > ~/.mcps/license.key
Trial includes:
⢠Full Enterprise features
⢠Zero-trust architecture
⢠AI threat detection
⢠SIEM integration
⢠Priority support
Purchase before trial expires: https://mcps-security.com/pricing
`);
return trialKey;
}
}
module.exports = McpsLicensing;