survey-mcp-server
Version:
Survey management server handling survey creation, response collection, analysis, and reporting with database access for data management
464 lines • 13.2 kB
JavaScript
export const configSchema = [
// MongoDB Configuration
{
name: 'mongodb.uri',
type: 'string',
required: true,
sensitive: true,
validation: {
pattern: /^mongodb:\/\/.+/,
minLength: 10,
custom: (value) => {
// Validate MongoDB URI format
try {
const url = new URL(value);
if (!url.protocol.startsWith('mongodb')) {
return { isValid: false, message: 'Must be a valid MongoDB URI' };
}
return { isValid: true };
}
catch {
return { isValid: false, message: 'Must be a valid URI format' };
}
}
},
description: 'MongoDB connection URI',
environmentVariable: 'MONGODB_URI'
},
{
name: 'mongodb.dbName',
type: 'string',
required: true,
validation: {
pattern: /^[a-zA-Z][a-zA-Z0-9_-]*$/,
minLength: 1,
maxLength: 64
},
description: 'MongoDB database name',
environmentVariable: 'MONGODB_DB_NAME'
},
{
name: 'devSyiaApi.uri',
type: 'string',
required: false,
sensitive: true,
validation: {
pattern: /^mongodb:\/\/.+/,
minLength: 10
},
description: 'Dev SYIA API MongoDB connection URI',
environmentVariable: 'MONGO_URI_DEV_SYIA_API'
},
{
name: 'devSyiaApi.dbName',
type: 'string',
required: false,
validation: {
pattern: /^[a-zA-Z][a-zA-Z0-9_-]*$/,
minLength: 1,
maxLength: 64
},
description: 'Dev SYIA API database name',
environmentVariable: 'DB_NAME_DEV_SYIA_API'
},
{
name: 'syiaEtlDev.uri',
type: 'string',
required: false,
sensitive: true,
validation: {
pattern: /^mongodb:\/\/.+/,
minLength: 10
},
description: 'SYIA ETL development MongoDB connection URI',
environmentVariable: 'MONGODB_URI_SYIA_ETL'
},
{
name: 'syiaEtlDev.dbName',
type: 'string',
required: false,
validation: {
pattern: /^[a-zA-Z][a-zA-Z0-9_-]*$/,
minLength: 1,
maxLength: 64
},
description: 'SYIA ETL development database name',
environmentVariable: 'DB_NAME_SYIA_ETL'
},
// Typesense Configuration
{
name: 'typesense.nodes.0.host',
type: 'string',
required: false,
validation: {
pattern: /^[a-zA-Z0-9.-]+$/,
minLength: 1,
maxLength: 255
},
default: 'localhost',
description: 'Typesense server host',
environmentVariable: 'TYPESENSE_HOST'
},
{
name: 'typesense.nodes.0.port',
type: 'number',
required: false,
validation: {
min: 1,
max: 65535
},
default: 8108,
description: 'Typesense server port',
environmentVariable: 'TYPESENSE_PORT'
},
{
name: 'typesense.nodes.0.protocol',
type: 'string',
required: false,
validation: {
enum: ['http', 'https']
},
default: 'http',
description: 'Typesense connection protocol',
environmentVariable: 'TYPESENSE_PROTOCOL'
},
{
name: 'typesense.apiKey',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 8,
maxLength: 256
},
description: 'Typesense API key',
environmentVariable: 'TYPESENSE_API_KEY'
},
{
name: 'typesense.connectionTimeoutSeconds',
type: 'number',
required: false,
validation: {
min: 1,
max: 300
},
default: 10,
description: 'Typesense connection timeout in seconds',
environmentVariable: 'TYPESENSE_TIMEOUT'
},
// API Keys
{
name: 'openai.apiKey',
type: 'string',
required: false,
sensitive: true,
validation: {
pattern: /^sk-[a-zA-Z0-9]+$/,
minLength: 20,
maxLength: 200
},
description: 'OpenAI API key',
environmentVariable: 'OPENAI_API_KEY'
},
{
name: 'perplexity.apiKey',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 20,
maxLength: 200
},
description: 'Perplexity AI API key',
environmentVariable: 'PERPLEXITY_API_KEY'
},
{
name: 'llama.apiKey',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 20,
maxLength: 200
},
description: 'Llama API key',
environmentVariable: 'LLAMA_API_KEY'
},
// API Configuration
{
name: 'api.baseUrl',
type: 'string',
required: false,
validation: {
pattern: /^https?:\/\/.+/,
custom: (value) => {
try {
new URL(value);
return { isValid: true };
}
catch {
return { isValid: false, message: 'Must be a valid URL' };
}
}
},
description: 'API base URL',
environmentVariable: 'API_BASE_URL'
},
{
name: 'api.token',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 20,
maxLength: 2000
},
description: 'API authentication token',
environmentVariable: 'API_TOKEN'
},
// Vendor Configuration
{
name: 'vendor.model',
type: 'string',
required: false,
validation: {
enum: ['gpt-4o', 'gpt-4', 'gpt-3.5-turbo', 'claude-3', 'llama-2']
},
default: 'gpt-4o',
description: 'AI model to use',
environmentVariable: 'VENDOR_MODEL'
},
{
name: 'vendor.temperature',
type: 'number',
required: false,
validation: {
min: 0,
max: 2
},
default: 0.1,
description: 'AI model temperature',
environmentVariable: 'VENDOR_TEMPERATURE'
},
// Downloads Configuration
{
name: 'downloads.baseDir',
type: 'string',
required: false,
validation: {
minLength: 1,
maxLength: 500,
custom: (value) => {
// Check for path traversal attempts
if (value.includes('../') || value.includes('..\\')) {
return { isValid: false, message: 'Path traversal attempts not allowed' };
}
return { isValid: true };
}
},
default: './downloads',
description: 'Base directory for downloads',
environmentVariable: 'DOWNLOADS_DIR'
},
// Classification Society Credentials (examples for main ones)
{
name: 'class.ccs.SMPL.username',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 1,
maxLength: 100
},
description: 'CCS SMPL username',
environmentVariable: 'CCS_SMPL_USERNAME'
},
{
name: 'class.ccs.SMPL.password',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 8,
maxLength: 100
},
description: 'CCS SMPL password',
environmentVariable: 'CCS_SMPL_PASSWORD'
},
{
name: 'class.nk.SMPL.username',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 1,
maxLength: 100
},
description: 'NK SMPL username',
environmentVariable: 'NK_SMPL_USERNAME'
},
{
name: 'class.nk.SMPL.password',
type: 'string',
required: false,
sensitive: true,
validation: {
minLength: 8,
maxLength: 100
},
description: 'NK SMPL password',
environmentVariable: 'NK_SMPL_PASSWORD'
},
// Logging Configuration
{
name: 'logging.level',
type: 'string',
required: false,
validation: {
enum: ['error', 'warn', 'info', 'debug', 'verbose']
},
default: 'info',
description: 'Logging level',
environmentVariable: 'LOG_LEVEL'
},
{
name: 'logging.file',
type: 'string',
required: false,
validation: {
maxLength: 500,
custom: (value) => {
// Check for path traversal attempts
if (value.includes('../') || value.includes('..\\')) {
return { isValid: false, message: 'Path traversal attempts not allowed' };
}
return { isValid: true };
}
},
description: 'Log file path',
environmentVariable: 'LOG_FILE'
},
// Security Configuration
{
name: 'security.enableInputValidation',
type: 'boolean',
required: false,
default: true,
description: 'Enable input validation middleware',
environmentVariable: 'SECURITY_ENABLE_INPUT_VALIDATION'
},
{
name: 'security.enableSanitization',
type: 'boolean',
required: false,
default: true,
description: 'Enable input sanitization',
environmentVariable: 'SECURITY_ENABLE_SANITIZATION'
},
{
name: 'security.maxRequestSize',
type: 'number',
required: false,
validation: {
min: 1024,
max: 100 * 1024 * 1024 // 100MB
},
default: 10 * 1024 * 1024, // 10MB
description: 'Maximum request size in bytes',
environmentVariable: 'SECURITY_MAX_REQUEST_SIZE'
},
{
name: 'security.rateLimitRequests',
type: 'number',
required: false,
validation: {
min: 1,
max: 10000
},
default: 100,
description: 'Rate limit requests per minute',
environmentVariable: 'SECURITY_RATE_LIMIT_REQUESTS'
},
// Performance Configuration
{
name: 'performance.enableCircuitBreaker',
type: 'boolean',
required: false,
default: true,
description: 'Enable circuit breaker pattern',
environmentVariable: 'PERFORMANCE_ENABLE_CIRCUIT_BREAKER'
},
{
name: 'performance.enableRetry',
type: 'boolean',
required: false,
default: true,
description: 'Enable retry logic',
environmentVariable: 'PERFORMANCE_ENABLE_RETRY'
},
{
name: 'performance.maxRetries',
type: 'number',
required: false,
validation: {
min: 0,
max: 10
},
default: 3,
description: 'Maximum number of retries',
environmentVariable: 'PERFORMANCE_MAX_RETRIES'
},
{
name: 'performance.timeoutMs',
type: 'number',
required: false,
validation: {
min: 1000,
max: 300000
},
default: 30000,
description: 'Default operation timeout in milliseconds',
environmentVariable: 'PERFORMANCE_TIMEOUT_MS'
}
];
// Environment-specific configuration overrides
export const developmentDefaults = {
'logging.level': 'debug',
'security.enableInputValidation': true,
'security.enableSanitization': true,
'performance.enableCircuitBreaker': false,
'performance.enableRetry': true
};
export const productionDefaults = {
'logging.level': 'warn',
'security.enableInputValidation': true,
'security.enableSanitization': true,
'performance.enableCircuitBreaker': true,
'performance.enableRetry': true,
'security.maxRequestSize': 5 * 1024 * 1024, // 5MB in production
'security.rateLimitRequests': 60 // More restrictive in production
};
export const testDefaults = {
'logging.level': 'error',
'security.enableInputValidation': true,
'security.enableSanitization': true,
'performance.enableCircuitBreaker': false,
'performance.enableRetry': false,
'performance.timeoutMs': 5000
};
export function getEnvironmentDefaults(environment) {
switch (environment.toLowerCase()) {
case 'development':
case 'dev':
return developmentDefaults;
case 'production':
case 'prod':
return productionDefaults;
case 'test':
case 'testing':
return testDefaults;
default:
return productionDefaults; // Default to production settings
}
}
//# sourceMappingURL=schema.js.map