mirror of
https://github.com/hanzoai/code.git
synced 2026-09-30 20:53:35 +00:00
Added an event for reinitializing all servers when config file is updated
This commit is contained in:
@@ -125,6 +125,16 @@ const MCPServersList = () => {
|
||||
}));
|
||||
});
|
||||
|
||||
// Subscribe to config file changes
|
||||
const disposableConfig = mcpConfigService.onDidUpdateConfigFile((response) => {
|
||||
const {mcpServers} = response;
|
||||
if (mcpServers) {
|
||||
// Reset all servers to "loading" state
|
||||
console.log('MCP Servers:', mcpServers);
|
||||
setMCPServers(mcpServers);
|
||||
}
|
||||
});
|
||||
|
||||
// Clean up subscription when component unmounts
|
||||
return () => disposable.dispose();
|
||||
}, [mcpConfigService]);
|
||||
|
||||
@@ -25,6 +25,7 @@ export interface IMCPConfigService {
|
||||
getMCPServers(): MCPServers;
|
||||
getAllToolsFormatted(): InternalToolInfo[];
|
||||
onDidChangeMCPServers: Event<MCPServerEmitterReturns>;
|
||||
onDidUpdateConfigFile: Event<MCPConfigFileUpdateReturns>;
|
||||
}
|
||||
|
||||
interface MCPServerEmitterReturns {
|
||||
@@ -32,6 +33,10 @@ interface MCPServerEmitterReturns {
|
||||
serverObject: MCPServerObject;
|
||||
}
|
||||
|
||||
interface MCPConfigFileUpdateReturns {
|
||||
mcpServers: MCPServers;
|
||||
}
|
||||
|
||||
export const IMCPConfigService = createDecorator<IMCPConfigService>('mcpConfigService');
|
||||
|
||||
class MCPConfigService extends Disposable implements IMCPConfigService {
|
||||
@@ -50,7 +55,9 @@ class MCPConfigService extends Disposable implements IMCPConfigService {
|
||||
|
||||
// Emitters for client
|
||||
private readonly _onDidChangeMCPServers = new Emitter<MCPServerEmitterReturns>();
|
||||
private readonly _onDidUpdateConfigFile = new Emitter<MCPConfigFileUpdateReturns>();
|
||||
public readonly onDidChangeMCPServers = this._onDidChangeMCPServers.event;
|
||||
public readonly onDidUpdateConfigFile = this._onDidUpdateConfigFile.event;
|
||||
|
||||
constructor(
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@@ -140,8 +147,12 @@ class MCPConfigService extends Disposable implements IMCPConfigService {
|
||||
formattedServers[serverName] = serverObject;
|
||||
}
|
||||
}
|
||||
// Fire the event to notify listeners
|
||||
this._onDidUpdateConfigFile.fire({ mcpServers: formattedServers });
|
||||
} else {
|
||||
this.mcpServers = {};
|
||||
// Fire the event to notify listeners
|
||||
this._onDidUpdateConfigFile.fire({ mcpServers: {} });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user