mcp: log when tools are loaded and refreshed (#244033)

This commit is contained in:
Connor Peet
2025-03-19 11:58:34 -07:00
committed by GitHub
parent 79abfa3cef
commit 54d3c4ae48
@@ -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);