mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 23:44:09 +01:00
mcp: log when tools are loaded and refreshed (#244033)
This commit is contained in:
@@ -255,19 +255,25 @@ export class McpServer extends Disposable implements IMcpServer {
|
||||
|
||||
const updateTools = (tx: ITransaction | undefined) => {
|
||||
const toolPromise = handler.capabilities.tools ? handler.listTools({}, cts.token) : Promise.resolve([]);
|
||||
const toolPromiseSafe = toolPromise.then(tools => tools.map(tool => {
|
||||
if (!tool.description) {
|
||||
// Ensure a description is provided for each tool, #243919
|
||||
handler.logger.warn(`Tool ${tool.name} does not have a description. Tools must be accurately described to be called`);
|
||||
tool.description = '<empty>';
|
||||
}
|
||||
const toolPromiseSafe = toolPromise.then(tools => {
|
||||
handler.logger.info(`Discovered ${tools.length} tools`);
|
||||
return tools.map(tool => {
|
||||
if (!tool.description) {
|
||||
// Ensure a description is provided for each tool, #243919
|
||||
handler.logger.warn(`Tool ${tool.name} does not have a description. Tools must be accurately described to be called`);
|
||||
tool.description = '<empty>';
|
||||
}
|
||||
|
||||
return tool;
|
||||
}));
|
||||
return tool;
|
||||
});
|
||||
});
|
||||
this.toolsFromServerPromise.set(new ObservablePromise(toolPromiseSafe), tx);
|
||||
};
|
||||
|
||||
store.add(handler.onDidChangeToolList(() => updateTools(undefined)));
|
||||
store.add(handler.onDidChangeToolList(() => {
|
||||
handler.logger.info('Tool list changed, refreshing tools...');
|
||||
updateTools(undefined);
|
||||
}));
|
||||
|
||||
transaction(tx => {
|
||||
updateTools(tx);
|
||||
|
||||
Reference in New Issue
Block a user