* 加载配置
()
| 19 | * 加载配置 |
| 20 | */ |
| 21 | private loadConfig(): void { |
| 22 | if (existsSync(this.configPath)) { |
| 23 | try { |
| 24 | const content = readFileSync(this.configPath, 'utf-8'); |
| 25 | this.config = JSON.parse(content); |
| 26 | } catch (error) { |
| 27 | console.warn('Failed to load MCP config, using defaults'); |
| 28 | this.config = this.getDefaultConfig(); |
| 29 | } |
| 30 | } else { |
| 31 | this.config = this.getDefaultConfig(); |
| 32 | } |
| 33 | |
| 34 | // 确保配置结构完整 |
| 35 | this.config = { |
| 36 | ...this.getDefaultConfig(), |
| 37 | ...this.config, |
| 38 | servers: { |
| 39 | ...this.getDefaultConfig().servers, |
| 40 | ...this.config.servers, |
| 41 | }, |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * 保存配置 |
no test coverage detected