userspecified

This commit is contained in:
Andrew Pareles 2025-05-21 21:33:05 -07:00
parent 18d1f2e6b9
commit 8b99b6ec78
2 changed files with 26 additions and 6 deletions

View file

@ -984,7 +984,9 @@ const MCPServer = ({ name, server }: { name: string, server: MCPServerObject })
const MCPServersList = () => {
const mcpServiceState = useMCPServiceState()
const accessor = useAccessor();
const mcpService = accessor.get('IMCPService');
const userSpecifiedMCPServerNames = mcpServiceState.userSpecifiedMCPServerNames
// TODO tell the user what servers they've specified (might be different from those found)
let content: React.ReactNode

View file

@ -25,21 +25,22 @@ type MCPState = {
mcpServerOfName: MCPServerOfName,
error: string | undefined,
isLoading: boolean, // TODO!!!!!!
userSpecifiedMCPServerNames: string[],
}
export interface IMCPService {
readonly _serviceBrand: undefined;
revealMCPConfigFile(): Promise<void>;
toggleMCPServer(serverName: string, isOn: boolean): Promise<void>;
readonly state: MCPState; // NOT persisted
onDidChangeState: Event<void>;
getCurrentMCPToolNames(): InternalToolInfo[];
getMCPToolFns(): {
callTool: MCPCallTool;
resultToString: MCPToolResultToString
};
readonly state: MCPState;
onDidChangeState: Event<void>;
getCurrentMCPToolNames(): InternalToolInfo[];
}
export const IMCPService = createDecorator<IMCPService>('mcpConfigService');
@ -78,6 +79,7 @@ class MCPService extends Disposable implements IMCPService {
mcpServerOfName: {},
error: undefined,
isLoading: false,
userSpecifiedMCPServerNames: [],
}
// Emitters for server events
@ -154,6 +156,20 @@ class MCPService extends Disposable implements IMCPService {
}
this._onDidChangeState.fire();
}
private readonly _setUserSpecifiedServerNames = async (names: string[]) => {
this.state = {
...this.state,
userSpecifiedMCPServerNames: names,
}
this._onDidChangeState.fire();
}
// private readonly _setIsLoading = async (isLoading: boolean) => {
// this.state = {
// ...this.state,
// isLoading: isLoading,
// }
// this._onDidChangeState.fire();
// }
@ -273,6 +289,8 @@ class MCPService extends Disposable implements IMCPService {
if (!mcpConfigFile) { console.log(`Not setting state: MCP config file not found`); return }
if (!mcpConfigFile?.mcpServers) { console.log(`Not setting state: MCP config file did not have an 'mcpServers' field`); return }
this._setUserSpecifiedServerNames(Object.keys(mcpConfigFile.mcpServers))
const currMCPStateOfName = this.voidSettingsService.state.mcpServerStateOfName;
const availableServers = Object.keys(mcpConfigFile.mcpServers);