Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ export async function activate(context: vscode.ExtensionContext) {
}
);

const settings = vscode.workspace.getConfiguration('Devdb');
if (settings.get<boolean>('enableMcpServer', true)) {
try {
await startHttpServer();
logToOutput('MCP HTTP server started', 'MCP Server');
} catch (error) {
vscode.window.showErrorMessage(`Failed to start MCP server: ${error}`);
}
}
await applyMcpServerSetting();

context.subscriptions.push(provider);

Expand Down Expand Up @@ -139,10 +131,15 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('devdb.license.manage', () => licenseService.manageLicense())
);

vscode.workspace.onDidChangeConfiguration((event: vscode.ConfigurationChangeEvent) => {
vscode.workspace.onDidChangeConfiguration(async (event: vscode.ConfigurationChangeEvent) => {
if (event.affectsConfiguration('Devdb')) {
devDbViewProvider?.notifyConfigChange(event);
}

// The setting is a switch, not a startup flag: honour it while running.
if (event.affectsConfiguration('Devdb.enableMcpServer')) {
await applyMcpServerSetting();
}
});

initializeDevWorkspaceProRecommendations(context);
Expand Down Expand Up @@ -202,6 +199,22 @@ function registerDevCommands(context: vscode.ExtensionContext) {
);
}

async function applyMcpServerSetting() {
const enabled = vscode.workspace.getConfiguration('Devdb').get<boolean>('enableMcpServer', true);

if (!enabled) {
stopHttpServer();
return;
}

try {
await startHttpServer();
logToOutput('MCP HTTP server started', 'MCP Server');
} catch (error) {
vscode.window.showErrorMessage(`Failed to start MCP server: ${error}`);
}
}

export function deactivate() {
stopHttpServer();
}