Skip to content

Commit 2e318bf

Browse files
replace configure mcp with update mcp function & hide notification on update
1 parent 4032a00 commit 2e318bf

2 files changed

Lines changed: 15 additions & 27 deletions

File tree

src/commands/configureMCP.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ export async function configureMCP(params?: RepositoryParams, isUpdate = false)
261261
if (generateRules === 'automatic') {
262262
await createOrUpdateRules(params)
263263
}
264-
await notifyMCPInstallation()
264+
if (!isUpdate) {
265+
await notifyMCPInstallation()
266+
}
265267
return
266268
} else {
267269
await installMCPForVSCode(codacyServer)

src/extension.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,17 @@ const registerGitProvider = async (context: vscode.ExtensionContext, codacyCloud
148148
if (git) {
149149
// register events
150150
git.onDidOpenRepository(async (repo: GitRepository) => {
151-
await codacyCloud.open(repo)
152-
// Configure MCP after repository is opened and params are available
153-
if (codacyCloud.params) {
154-
configureMCP(codacyCloud.params, isMCPConfigured()).catch((error) => {
155-
Logger.warn(`Failed to configure MCP: ${error}`)
151+
try {
152+
await codacyCloud.open(repo)
153+
// update MCP after repository is opened and params are available
154+
updateMCPConfig(codacyCloud.params).catch((error) => {
155+
Logger.warn(`Failed to update MCP config: ${error instanceof Error ? error.message : String(error)}`)
156156
})
157-
} else {
158-
Logger.debug('Repository params not yet available, will configure MCP later')
157+
} catch (error) {
158+
Logger.error(`Failed to open repository: ${error instanceof Error ? error.message : String(error)}`)
159159
}
160160
})
161161

162-
// Configure MCP when repository is fully loaded and params are definitely available
163-
codacyCloud.onDidLoadRepository(() => {
164-
configureMCP(codacyCloud.params, isMCPConfigured()).catch((error) => {
165-
Logger.warn(`Failed to configure MCP after repository load: ${error}`)
166-
})
167-
})
168-
169162
git.onDidCloseRepository((repo: GitRepository) => {
170163
codacyCloud.close(repo)
171164
// Only set context to false if there are truly no repositories left
@@ -180,12 +173,8 @@ const registerGitProvider = async (context: vscode.ExtensionContext, codacyCloud
180173
if (git.repositories.length > 0) {
181174
Logger.debug(`Git API initialized with ${git.repositories.length} repositories`)
182175
await codacyCloud.open(git.repositories[0])
183-
// Configure MCP after repository is opened and params are available
184-
if (codacyCloud.params) {
185-
await configureMCP(codacyCloud.params, isMCPConfigured())
186-
} else {
187-
Logger.debug('Repository params not yet available, will configure MCP later')
188-
}
176+
// Update MCP config after repository is opened and params are available
177+
await updateMCPConfig(codacyCloud.params)
189178
} else {
190179
Logger.appendLine('Git API initialized but no repositories found')
191180
codacyCloud.clear()
@@ -286,6 +275,9 @@ export async function activate(context: vscode.ExtensionContext) {
286275
}
287276
}
288277

278+
// Configure MCP automatically
279+
await configureMCP(codacyCloud.params, isMCPConfigured())
280+
289281
await registerCommands(context, codacyCloud)
290282

291283
// add views
@@ -356,12 +348,6 @@ export async function activate(context: vscode.ExtensionContext) {
356348
if (gitProvider.state === 'initialized' && gitProvider.repositories.length > 0) {
357349
Logger.debug(`Found ${gitProvider.repositories.length} repositories, opening first one`)
358350
await codacyCloud.open(gitProvider.repositories[0])
359-
// Configure MCP after repository is opened and params are available
360-
if (codacyCloud.params) {
361-
await configureMCP(codacyCloud.params, isMCPConfigured())
362-
} else {
363-
Logger.debug('Repository params not yet available, will configure MCP later')
364-
}
365351
} else if (gitProvider.state === 'uninitialized') {
366352
Logger.debug('Git API is still initializing, will wait for state change event')
367353
} else {

0 commit comments

Comments
 (0)