@kyaniiii/google-search-mcp
Version:
MCP server for Google Search with API key rotation
51 lines • 1.89 kB
JavaScript
import { GlobalConfigManager } from './global-config.js';
export class GoogleSearchConfig {
globalConfig;
constructor() {
this.globalConfig = new GlobalConfigManager();
this.checkConfiguration();
}
checkConfiguration() {
if (!this.globalConfig.hasValidConfig()) {
console.error('[WARN] No Google API keys configured.');
console.error('[INFO] First time setup:');
console.error('[INFO] 1. Get API keys: https://console.cloud.google.com/');
console.error('[INFO] 2. Get Search Engine ID: https://programmablesearchengine.google.com/');
console.error('[INFO] 3. Run setup command: npx @kyaniiii/google-search-mcp setup');
console.error('[INFO] Full documentation: https://github.com/Fabien-desablens/google-search-mcp#readme');
return;
}
const status = this.globalConfig.getQuotaStatus();
console.error(`[INFO] ${status.keysStatus.length} Google API keys loaded globally`);
}
getAvailableKey() {
const key = this.globalConfig.getAvailableKey();
if (!key)
return null;
return {
id: key.id,
apiKey: key.apiKey,
searchEngineId: key.searchEngineId,
dailyUsage: key.dailyUsage,
dailyLimit: key.dailyLimit,
lastReset: key.lastReset,
isActive: key.isActive
};
}
incrementUsage(keyId) {
this.globalConfig.incrementUsage(keyId);
}
getQuotaStatus() {
return this.globalConfig.getQuotaStatus();
}
disableKey(keyId, reason) {
this.globalConfig.disableKey(keyId, reason);
}
hasValidConfig() {
return this.globalConfig.hasValidConfig();
}
getConfigPath() {
return this.globalConfig.getConfigPath();
}
}
//# sourceMappingURL=config.js.map