Merge pull request #6224 from continuedev/fix-atmention-dropdown-mcp-refresh

Add MCP provider refresh for @mention dropdown submenu items
This commit is contained in:
Patrick Erichsen 2025-06-20 18:21:17 -07:00 • committed by GitHub
commit 613ce91ded
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,6 +42,7 @@ import {
IdeSettings,
ModelDescription,
RangeInFile,
ToolCall,
type ContextItem,
type ContextItemId,
type IDE,
@ -147,6 +148,18 @@ export class Core {
MCPManagerSingleton.getInstance().onConnectionsRefreshed = () => {
void this.configHandler.reloadConfig();
// Refresh @mention dropdown submenu items for MCP providers
const mcpManager = MCPManagerSingleton.getInstance();
const mcpProviderNames = Array.from(mcpManager.connections.keys()).map(
(mcpId) => `mcp-${mcpId}`,
);
if (mcpProviderNames.length > 0) {
this.messenger.send("refreshSubmenuItems", {
providers: mcpProviderNames,
});
}
};
this.codeBaseIndexer = new CodebaseIndexer(
@ -743,44 +756,9 @@ export class Core {
return { url };
});
on("tools/call", async ({ data: { toolCall } }) => {
const { config } = await this.configHandler.loadConfig();
if (!config) {
throw new Error("Config not loaded");
}
const tool = config.tools.find(
(t) => t.function.name === toolCall.function.name,
);
if (!tool) {
throw new Error(`Tool ${toolCall.function.name} not found`);
}
if (!config.selectedModelByRole.chat) {
throw new Error("No chat model selected");
}
// Define a callback for streaming output updates
const onPartialOutput = (params: {
toolCallId: string;
contextItems: ContextItem[];
}) => {
this.messenger.send("toolCallPartialOutput", params);
};
return await callTool(tool, toolCall, {
config,
ide: this.ide,
llm: config.selectedModelByRole.chat,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
tool,
toolCallId: toolCall.id,
onPartialOutput,
codeBaseIndexer: this.codeBaseIndexer,
});
});
on("tools/call", async ({ data: { toolCall } }) =>
this.handleToolCall(toolCall),
);
on("isItemTooBig", async ({ data: { item } }) => {
return this.isItemTooBig(item);
@ -805,6 +783,45 @@ export class Core {
});
}
private async handleToolCall(toolCall: ToolCall) {
const { config } = await this.configHandler.loadConfig();
if (!config) {
throw new Error("Config not loaded");
}
const tool = config.tools.find(
(t) => t.function.name === toolCall.function.name,
);
if (!tool) {
throw new Error(`Tool ${toolCall.function.name} not found`);
}
if (!config.selectedModelByRole.chat) {
throw new Error("No chat model selected");
}
// Define a callback for streaming output updates
const onPartialOutput = (params: {
toolCallId: string;
contextItems: ContextItem[];
}) => {
this.messenger.send("toolCallPartialOutput", params);
};
return await callTool(tool, toolCall, {
config,
ide: this.ide,
llm: config.selectedModelByRole.chat,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
tool,
toolCallId: toolCall.id,
onPartialOutput,
codeBaseIndexer: this.codeBaseIndexer,
});
}
private async isItemTooBig(item: ContextItemWithId) {
const { config } = await this.configHandler.loadConfig();
if (!config) {