@coretext-ai/qa-gsuite-f47ac10b-58cc-4372-a567-0e02b2c3d479
Version:
MCP server with GSuite (Contacts, Drive, Gmail, Calendar) integration
144 lines • 7.61 kB
JavaScript
export function loadConfig() {
return {
// Log shipping configuration
logShipping: {
enabled: process.env.LOG_SHIPPING_ENABLED === 'true',
endpoint: process.env.LOG_INGESTION_URL || '',
...(process.env.LOG_INGESTION_API_KEY && { apiKey: process.env.LOG_INGESTION_API_KEY }),
requireApiKey: process.env.LOG_SHIPPING_REQUIRE_API_KEY === 'true',
batchSize: parseInt(process.env.LOG_SHIPPING_BATCH_SIZE || '500', 10),
flushInterval: parseInt(process.env.LOG_SHIPPING_INTERVAL || '5000', 10),
maxRetries: parseInt(process.env.LOG_SHIPPING_MAX_RETRIES || '3', 10),
logLevel: (process.env.LOG_LEVEL || 'ERROR')
},
googleContacts: {
gOOGLEOAUTHCREDENTIALS: process.env.GOOGLE_OAUTH_CREDENTIALS || '',
oauth: {
"provider": "google",
"scopes": [
"https://www.googleapis.com/auth/contacts",
"https://www.googleapis.com/auth/contacts.readonly",
"https://www.googleapis.com/auth/contacts.other.readonly",
"https://www.googleapis.com/auth/directory.readonly",
"https://www.googleapis.com/auth/user.addresses.read",
"https://www.googleapis.com/auth/user.emails.read",
"https://www.googleapis.com/auth/user.phonenumbers.read",
"https://www.googleapis.com/auth/userinfo.profile"
],
"credentialFileEnv": "GOOGLE_OAUTH_CREDENTIALS",
"redirectUri": "http://localhost:3000/oauth/callback",
"tokenStoragePath": "~/.mcp/google-tokens/"
},
},
googleDrive: {
gOOGLEOAUTHCREDENTIALS: process.env.GOOGLE_OAUTH_CREDENTIALS || '',
oauth: {
"provider": "google",
"scopes": [
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive.metadata.readonly"
],
"credentialFileEnv": "GOOGLE_OAUTH_CREDENTIALS",
"redirectUri": "http://localhost:3000/oauth/callback",
"tokenStoragePath": "~/.mcp/google-tokens/"
},
},
googleGmail: {
gOOGLEOAUTHCREDENTIALS: process.env.GOOGLE_OAUTH_CREDENTIALS || '',
oauth: {
"provider": "google",
"scopes": [
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.labels",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.send",
"https://www.googleapis.com/auth/gmail.settings.basic"
],
"credentialFileEnv": "GOOGLE_OAUTH_CREDENTIALS",
"redirectUri": "http://localhost:3000/oauth/callback",
"tokenStoragePath": "~/.mcp/google-tokens/"
},
},
googleCalendar: {
gOOGLEOAUTHCREDENTIALS: process.env.GOOGLE_OAUTH_CREDENTIALS || '',
oauth: {
"provider": "google",
"scopes": [
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/calendar.readonly",
"https://www.googleapis.com/auth/calendar.events",
"https://www.googleapis.com/auth/calendar.events.readonly",
"https://www.googleapis.com/auth/calendar.acls",
"https://www.googleapis.com/auth/calendar.acls.readonly",
"https://www.googleapis.com/auth/calendar.app.created",
"https://www.googleapis.com/auth/calendar.calendarlist",
"https://www.googleapis.com/auth/calendar.calendarlist.readonly",
"https://www.googleapis.com/auth/calendar.calendars",
"https://www.googleapis.com/auth/calendar.calendars.readonly",
"https://www.googleapis.com/auth/calendar.events.freebusy",
"https://www.googleapis.com/auth/calendar.events.owned",
"https://www.googleapis.com/auth/calendar.events.owned.readonly",
"https://www.googleapis.com/auth/calendar.events.public.readonly",
"https://www.googleapis.com/auth/calendar.settings.readonly"
],
"credentialFileEnv": "GOOGLE_OAUTH_CREDENTIALS",
"redirectUri": "http://localhost:3000/oauth/callback",
"tokenStoragePath": "~/.mcp/google-tokens/"
},
},
};
}
export function validateConfig(config) {
const errors = [];
// Validate log shipping configuration
if (config.logShipping.enabled) {
if (!config.logShipping.endpoint) {
errors.push('LOG_INGESTION_URL environment variable is required when log shipping is enabled');
}
// API key validation based on requireApiKey flag
if (config.logShipping.requireApiKey && !config.logShipping.apiKey) {
errors.push('LOG_INGESTION_API_KEY environment variable is required when LOG_SHIPPING_REQUIRE_API_KEY is true');
}
// Warning for missing API key (not an error during transition)
if (!config.logShipping.apiKey && !config.logShipping.requireApiKey) {
console.warn('[CONFIG WARNING] LOG_INGESTION_API_KEY not set. Log shipping will work now but will require an API key in the future.');
console.warn('[CONFIG WARNING] Set LOG_INGESTION_API_KEY to prepare for future requirements.');
}
if (config.logShipping.endpoint && !config.logShipping.endpoint.startsWith('https://')) {
errors.push('LOG_INGESTION_URL must use HTTPS protocol');
}
if (config.logShipping.batchSize < 1 || config.logShipping.batchSize > 1000) {
errors.push('LOG_SHIPPING_BATCH_SIZE must be between 1 and 1000');
}
if (config.logShipping.flushInterval < 1000) {
errors.push('LOG_SHIPPING_INTERVAL must be at least 1000ms');
}
if (!['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].includes(config.logShipping.logLevel)) {
errors.push('LOG_LEVEL must be one of: DEBUG, INFO, WARN, ERROR, FATAL');
}
}
// Validate google-contacts configuration
if (!config.googleContacts.gOOGLEOAUTHCREDENTIALS) {
errors.push('GOOGLE_OAUTH_CREDENTIALS environment variable is required for google-contacts');
}
// Validate google-drive configuration
if (!config.googleDrive.gOOGLEOAUTHCREDENTIALS) {
errors.push('GOOGLE_OAUTH_CREDENTIALS environment variable is required for google-drive');
}
// Validate google-gmail configuration
if (!config.googleGmail.gOOGLEOAUTHCREDENTIALS) {
errors.push('GOOGLE_OAUTH_CREDENTIALS environment variable is required for google-gmail');
}
// Validate google-calendar configuration
if (!config.googleCalendar.gOOGLEOAUTHCREDENTIALS) {
errors.push('GOOGLE_OAUTH_CREDENTIALS environment variable is required for google-calendar');
}
return {
isValid: errors.length === 0,
errors
};
}
//# sourceMappingURL=config.js.map