* Restart a specific server
(serverName: string)
| 216 | * Restart a specific server |
| 217 | */ |
| 218 | public async restartServer(serverName: string): Promise<void> { |
| 219 | if (!this.assistant || !this.assistant.mcpServers) return; |
| 220 | |
| 221 | const serverConfig = this.assistant.mcpServers.find( |
| 222 | (s, index) => s && (s.name || `server-${index}`) === serverName, |
| 223 | ); |
| 224 | |
| 225 | if (!serverConfig) { |
| 226 | throw new Error(`Server ${serverName} not found in configuration`); |
| 227 | } |
| 228 | |
| 229 | const existingConnection = this.connections.get(serverName); |
| 230 | if (existingConnection) { |
| 231 | if (existingConnection.status === "connected") { |
| 232 | await this.shutdownConnection(existingConnection); |
| 233 | } |
| 234 | this.connections.delete(serverName); |
| 235 | } |
| 236 | await this.connectServer(serverConfig); |
| 237 | } |
| 238 | |
| 239 | private async connectServer(serverConfig: MCPServerConfig) { |
| 240 | const connection: ServerConnection = { |
no test coverage detected