// Legal disclaimers and compliance utilities for MCP Sigmund
// This module ensures all system outputs include proper legal disclaimers
import { LegalDisclaimer } from './types.js';
// Standard legal disclaimer text
export const STANDARD_DISCLAIMER_TEXT = `
⚠️ IMPORTANT LEGAL DISCLAIMER
MCP Sigmund is an educational learning resource and data analysis tool, NOT a financial advisor or advisory service.
🚫 NOT FINANCIAL ADVICE
- This system does NOT provide financial advice, recommendations, or guidance
- All insights, analysis, and suggestions are for educational purposes only
- Users must make their own financial decisions based on their own research and judgment
- No information from this system should be considered as investment, tax, or financial advice
📚 EDUCATIONAL PURPOSE ONLY
- MCP Sigmund is designed as a learning resource for understanding personal financial data
- The system helps users analyze and understand their financial patterns and trends
- All outputs are intended for educational and informational purposes
- Users should consult qualified financial professionals for actual financial advice
By using MCP Sigmund, you acknowledge this is an educational tool, not a financial advisory service.
`.trim();
// Short disclaimer for API responses
export const SHORT_DISCLAIMER_TEXT = `
⚠️ DISCLAIMER: This is an educational tool, not financial advice. All insights are for learning purposes only. Consult qualified professionals for financial advice.
`.trim();
// Legal disclaimer generator
export function generateLegalDisclaimer(): LegalDisclaimer {
return {
educational_purpose_only: true,
not_financial_advice: true,
user_responsibility: true,
disclaimer_text: STANDARD_DISCLAIMER_TEXT,
timestamp: new Date(),
};
}
// Short disclaimer generator for API responses
export function generateShortDisclaimer(): LegalDisclaimer {
return {
educational_purpose_only: true,
not_financial_advice: true,
user_responsibility: true,
disclaimer_text: SHORT_DISCLAIMER_TEXT,
timestamp: new Date(),
};
}
// Add disclaimer to any response object
export function addDisclaimerToResponse<T extends Record<string, unknown>>(
response: T,
useShortDisclaimer = false
): T & { legal_disclaimer: LegalDisclaimer } {
const disclaimer = useShortDisclaimer
? generateShortDisclaimer()
: generateLegalDisclaimer();
return {
...response,
legal_disclaimer: disclaimer,
};
}
// Validate that disclaimer is present in response
export function validateDisclaimerPresent(
response: Record<string, unknown>
): boolean {
return (
'legal_disclaimer' in response &&
typeof response.legal_disclaimer === 'object' &&
response.legal_disclaimer !== null &&
'educational_purpose_only' in (response.legal_disclaimer as Record<string, unknown>) &&
'not_financial_advice' in (response.legal_disclaimer as Record<string, unknown>)
);
}
// Compliance check for all system responses
export function performComplianceCheck(
response: Record<string, unknown>
): {
compliant: boolean;
missing_elements: string[];
warnings: string[];
} {
const missing_elements: string[] = [];
const warnings: string[] = [];
// Check if disclaimer is present
if (!validateDisclaimerPresent(response)) {
missing_elements.push('legal_disclaimer');
}
// Check for potentially problematic language
const responseString = JSON.stringify(response).toLowerCase();
const problematicTerms = [
'recommend',
'advise',
'suggest',
'should invest',
'buy',
'sell',
'guarantee',
'promise',
];
for (const term of problematicTerms) {
if (responseString.includes(term)) {
warnings.push(`Potentially problematic term found: "${term}"`);
}
}
return {
compliant: missing_elements.length === 0,
missing_elements,
warnings,
};
}
// Educational purpose validator
export function validateEducationalPurpose(
content: string
): {
is_educational: boolean;
educational_indicators: string[];
concerns: string[];
} {
const educationalIndicators = [
'educational',
'learning',
'analysis',
'understanding',
'insight',
'pattern',
'trend',
'data',
'information',
];
const concerns = [
'recommendation',
'advice',
'should',
'must',
'guarantee',
'promise',
'investment',
'buy',
'sell',
];
const contentLower = content.toLowerCase();
const foundIndicators = educationalIndicators.filter((indicator) =>
contentLower.includes(indicator)
);
const foundConcerns = concerns.filter((concern) =>
contentLower.includes(concern)
);
return {
is_educational: foundIndicators.length > 0 && foundConcerns.length === 0,
educational_indicators: foundIndicators,
concerns: foundConcerns,
};
}
// Export all disclaimer constants and functions
export const LEGAL_DISCLAIMERS = {
STANDARD_DISCLAIMER_TEXT,
SHORT_DISCLAIMER_TEXT,
generateLegalDisclaimer,
generateShortDisclaimer,
addDisclaimerToResponse,
validateDisclaimerPresent,
performComplianceCheck,
validateEducationalPurpose,
} as const;