Skip to content

Commit 519f75d

Browse files
authored
revert: revert for all commits for emergency deployment (aws#1966)
* Revert "fix: fix for mcp delete to remove it from mcp config file (aws#1956)" This reverts commit ad71312. * Revert "fix(amazonq): stop continuous monitor when WCS sees ServiceQuotaExceeded (aws#1957)" This reverts commit 81e19b9. * Revert "feat: enable webforms to blazor transformation via validation bypass (aws#1929)" This reverts commit 528f820. * Revert "fix: dependency vulnerabilities (aws#1953)" This reverts commit 2980dab.
1 parent ad71312 commit 519f75d

File tree

9 files changed

+25
-452
lines changed

9 files changed

+25
-452
lines changed

package-lock.json

Lines changed: 10 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpEventHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class McpEventHandler {
242242
*/
243243

244244
async onMcpServerClick(params: McpServerClickParams) {
245-
this.#features.logging.log(`onMcpServerClick event with params: ${JSON.stringify(params)}`)
245+
this.#features.logging.log(`[VSCode Server] onMcpServerClick event with params: ${JSON.stringify(params)}`)
246246

247247
// Use a map of handlers for different action types
248248
const handlers: Record<string, () => Promise<any>> = {
@@ -1143,6 +1143,7 @@ export class McpEventHandler {
11431143
this.#pendingPermissionConfig = undefined
11441144

11451145
this.#features.logging.info(`Applied permission changes for server: ${serverName}`)
1146+
this.#isProgrammaticChange = false
11461147
return { id: params.id }
11471148
} catch (error) {
11481149
this.#features.logging.error(`Failed to save MCP permissions: ${error}`)

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpManager.test.ts

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const fakeWorkspace = {
2626
mkdir: (_: string, __: any) => Promise.resolve(),
2727
},
2828
getUserHomeDir: () => '',
29-
getAllWorkspaceFolders: () => [{ uri: '/fake/workspace' }],
3029
}
3130
const features = { logging: fakeLogging, workspace: fakeWorkspace, lsp: {} } as any
3231

@@ -235,26 +234,10 @@ describe('addServer()', () => {
235234
describe('removeServer()', () => {
236235
let loadStub: sinon.SinonStub
237236
let saveAgentConfigStub: sinon.SinonStub
238-
let existsStub: sinon.SinonStub
239-
let readFileStub: sinon.SinonStub
240-
let writeFileStub: sinon.SinonStub
241-
let mkdirStub: sinon.SinonStub
242-
let getWorkspaceMcpConfigPathsStub: sinon.SinonStub
243-
let getGlobalMcpConfigPathStub: sinon.SinonStub
244237

245238
beforeEach(() => {
246239
loadStub = stubAgentConfig()
247240
saveAgentConfigStub = sinon.stub(mcpUtils, 'saveAgentConfig').resolves()
248-
existsStub = sinon.stub(fakeWorkspace.fs, 'exists').resolves(true)
249-
readFileStub = sinon
250-
.stub(fakeWorkspace.fs, 'readFile')
251-
.resolves(Buffer.from(JSON.stringify({ mcpServers: { x: {} } })))
252-
writeFileStub = sinon.stub(fakeWorkspace.fs, 'writeFile').resolves()
253-
mkdirStub = sinon.stub(fakeWorkspace.fs, 'mkdir').resolves()
254-
getWorkspaceMcpConfigPathsStub = sinon
255-
.stub(mcpUtils, 'getWorkspaceMcpConfigPaths')
256-
.returns(['ws1/config.json', 'ws2/config.json'])
257-
getGlobalMcpConfigPathStub = sinon.stub(mcpUtils, 'getGlobalMcpConfigPath').returns('global/config.json')
258241
})
259242

260243
afterEach(async () => {
@@ -292,106 +275,6 @@ describe('removeServer()', () => {
292275
expect(saveAgentConfigStub.calledOnce).to.be.true
293276
expect((mgr as any).clients.has('x')).to.be.false
294277
})
295-
296-
it('removes server from all config files', async () => {
297-
const mgr = await McpManager.init([], features)
298-
const dummy = new Client({ name: 'c', version: 'v' })
299-
;(mgr as any).clients.set('x', dummy)
300-
;(mgr as any).mcpServers.set('x', {
301-
command: '',
302-
args: [],
303-
env: {},
304-
timeout: 0,
305-
__configPath__: 'c.json',
306-
} as MCPServerConfig)
307-
;(mgr as any).serverNameMapping.set('x', 'x')
308-
;(mgr as any).agentConfig = {
309-
name: 'test-agent',
310-
version: '1.0.0',
311-
description: 'Test agent',
312-
mcpServers: { x: {} },
313-
tools: ['@x'],
314-
allowedTools: [],
315-
toolsSettings: {},
316-
includedFiles: [],
317-
resources: [],
318-
}
319-
320-
await mgr.removeServer('x')
321-
322-
// Verify that writeFile was called for each config path (2 workspace + 1 global)
323-
expect(writeFileStub.callCount).to.equal(3)
324-
325-
// Verify the content of the writes (should have removed the server)
326-
writeFileStub.getCalls().forEach(call => {
327-
const content = JSON.parse(call.args[1])
328-
expect(content.mcpServers).to.not.have.property('x')
329-
})
330-
})
331-
})
332-
333-
describe('mutateConfigFile()', () => {
334-
let existsStub: sinon.SinonStub
335-
let readFileStub: sinon.SinonStub
336-
let writeFileStub: sinon.SinonStub
337-
let mkdirStub: sinon.SinonStub
338-
let mgr: McpManager
339-
340-
beforeEach(async () => {
341-
sinon.restore()
342-
stubAgentConfig()
343-
existsStub = sinon.stub(fakeWorkspace.fs, 'exists').resolves(true)
344-
readFileStub = sinon
345-
.stub(fakeWorkspace.fs, 'readFile')
346-
.resolves(Buffer.from(JSON.stringify({ mcpServers: { test: {} } })))
347-
writeFileStub = sinon.stub(fakeWorkspace.fs, 'writeFile').resolves()
348-
mkdirStub = sinon.stub(fakeWorkspace.fs, 'mkdir').resolves()
349-
mgr = await McpManager.init([], features)
350-
})
351-
352-
afterEach(async () => {
353-
sinon.restore()
354-
try {
355-
await McpManager.instance.close()
356-
} catch {}
357-
})
358-
359-
it('reads, mutates, and writes config file', async () => {
360-
// Access the private method using type assertion
361-
const mutateConfigFile = (mgr as any).mutateConfigFile.bind(mgr)
362-
363-
await mutateConfigFile('test/path.json', (json: any) => {
364-
json.mcpServers.newServer = { command: 'test' }
365-
delete json.mcpServers.test
366-
})
367-
368-
expect(readFileStub.calledOnce).to.be.true
369-
expect(writeFileStub.calledOnce).to.be.true
370-
371-
// Verify the content was modified correctly
372-
const writtenContent = JSON.parse(writeFileStub.firstCall.args[1])
373-
expect(writtenContent.mcpServers).to.have.property('newServer')
374-
expect(writtenContent.mcpServers).to.not.have.property('test')
375-
})
376-
377-
it('creates new config file if it does not exist', async () => {
378-
existsStub.resolves(false)
379-
readFileStub.rejects({ code: 'ENOENT' })
380-
381-
// Access the private method using type assertion
382-
const mutateConfigFile = (mgr as any).mutateConfigFile.bind(mgr)
383-
384-
await mutateConfigFile('test/path.json', (json: any) => {
385-
json.mcpServers.newServer = { command: 'test' }
386-
})
387-
388-
expect(mkdirStub.calledOnce).to.be.true
389-
expect(writeFileStub.calledOnce).to.be.true
390-
391-
// Verify the content was created correctly
392-
const writtenContent = JSON.parse(writeFileStub.firstCall.args[1])
393-
expect(writtenContent.mcpServers).to.have.property('newServer')
394-
})
395278
})
396279

397280
describe('updateServer()', () => {

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpManager.ts

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@ import {
1414
McpServerRuntimeState,
1515
McpServerStatus,
1616
McpPermissionType,
17+
PersonaModel,
1718
MCPServerPermission,
1819
AgentConfig,
1920
} from './mcpTypes'
20-
import {
21-
isEmptyEnv,
22-
loadAgentConfig,
23-
saveAgentConfig,
24-
sanitizeName,
25-
getGlobalAgentConfigPath,
26-
getWorkspaceMcpConfigPaths,
27-
getGlobalMcpConfigPath,
28-
} from './mcpUtils'
21+
import { isEmptyEnv, loadAgentConfig, saveAgentConfig, sanitizeName, getGlobalAgentConfigPath } from './mcpUtils'
2922
import { AgenticChatError } from '../../errors'
3023
import { EventEmitter } from 'events'
3124
import { Mutex } from 'async-mutex'
@@ -665,30 +658,6 @@ export class McpManager {
665658

666659
// Save agent config
667660
await saveAgentConfig(this.features.workspace, this.features.logging, this.agentConfig, cfg.__configPath__)
668-
669-
// Get all config paths and delete the server from each one
670-
const wsUris = this.features.workspace.getAllWorkspaceFolders()?.map(f => f.uri) ?? []
671-
const wsConfigPaths = getWorkspaceMcpConfigPaths(wsUris)
672-
const globalConfigPath = getGlobalMcpConfigPath(this.features.workspace.fs.getUserHomeDir())
673-
const allConfigPaths = [...wsConfigPaths, globalConfigPath]
674-
675-
// Delete the server from all config files
676-
for (const configPath of allConfigPaths) {
677-
try {
678-
await this.mutateConfigFile(configPath, json => {
679-
if (json.mcpServers && json.mcpServers[unsanitizedName]) {
680-
delete json.mcpServers[unsanitizedName]
681-
this.features.logging.info(
682-
`Deleted server '${unsanitizedName}' from config file: ${configPath}`
683-
)
684-
}
685-
})
686-
} catch (err) {
687-
this.features.logging.warn(
688-
`Failed to delete server '${unsanitizedName}' from config file ${configPath}: ${err}`
689-
)
690-
}
691-
}
692661
}
693662

694663
this.mcpServers.delete(serverName)
@@ -1078,46 +1047,6 @@ export class McpManager {
10781047
}
10791048
}
10801049

1081-
/**
1082-
* Read, mutate, and write the MCP JSON config at the given path.
1083-
* @private
1084-
*/
1085-
private async mutateConfigFile(configPath: string, mutator: (json: any) => void): Promise<void> {
1086-
return McpManager.configMutex
1087-
.runExclusive(async () => {
1088-
let json: any = { mcpServers: {} }
1089-
try {
1090-
const raw = await this.features.workspace.fs.readFile(configPath)
1091-
this.features.logging.info(`Updating MCP config file: ${configPath}`)
1092-
const existing = JSON.parse(raw.toString())
1093-
json = { mcpServers: {}, ...existing }
1094-
} catch (err: any) {
1095-
// ignore fire not exist error
1096-
if (err?.code !== 'ENOENT') throw err
1097-
}
1098-
mutator(json)
1099-
1100-
let fsPath: string
1101-
try {
1102-
const uri = URI.parse(configPath)
1103-
fsPath = uri.scheme === 'file' ? uri.fsPath : configPath
1104-
} catch {
1105-
fsPath = configPath
1106-
}
1107-
fsPath = path.normalize(fsPath)
1108-
1109-
const dir = path.dirname(fsPath)
1110-
await this.features.workspace.fs.mkdir(dir, { recursive: true })
1111-
1112-
await this.features.workspace.fs.writeFile(fsPath, JSON.stringify(json, null, 2))
1113-
this.features.logging.debug(`MCP config file write complete: ${configPath}`)
1114-
})
1115-
.catch((e: any) => {
1116-
this.features.logging.error(`MCP: failed to update config at ${configPath}: ${e.message}`)
1117-
throw e
1118-
})
1119-
}
1120-
11211050
public getOriginalToolNames(namespacedName: string): { serverName: string; toolName: string } | undefined {
11221051
return this.toolNameMapping.get(namespacedName)
11231052
}

server/aws-lsp-codewhisperer/src/language-server/netTransform/tests/validation.test.ts

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai'
22
import { StartTransformRequest, TransformProjectMetadata } from '../models'
3-
import { isProject, isSolution, validateProject, validateSolution } from '../validation'
3+
import { isProject, isSolution, validateProject } from '../validation'
44
import { supportedProjects, unsupportedViewComponents } from '../resources/SupportedProjects'
55
import mock = require('mock-fs')
66
import { Logging } from '@aws/language-server-runtimes/server-interface'
@@ -96,72 +96,4 @@ describe('Test validation functionality', () => {
9696

9797
expect(validateProject(mockStartTransformationRequest, mockedLogging)).to.equal(false)
9898
})
99-
100-
// New tests for AspNetWebForms validation
101-
it('should return true when project is AspNetWebForms type', () => {
102-
let mockStartTransformationRequest: StartTransformRequest = sampleStartTransformRequest
103-
const mockProjectMeta = {
104-
Name: '',
105-
ProjectTargetFramework: '',
106-
ProjectPath: 'test.csproj',
107-
SourceCodeFilePaths: [],
108-
ProjectLanguage: '',
109-
ProjectType: 'AspNetWebForms',
110-
ExternalReferences: [],
111-
}
112-
mockStartTransformationRequest.ProjectMetadata = []
113-
mockStartTransformationRequest.ProjectMetadata.push(mockProjectMeta)
114-
115-
expect(validateProject(mockStartTransformationRequest, mockedLogging)).to.equal(true)
116-
})
117-
118-
it('should not include AspNetWebForms in unsupported projects list', () => {
119-
let mockStartTransformationRequest: StartTransformRequest = sampleStartTransformRequest
120-
121-
// Add a supported project
122-
const supportedProjectMeta = {
123-
Name: 'Supported',
124-
ProjectTargetFramework: '',
125-
ProjectPath: 'supported.csproj',
126-
SourceCodeFilePaths: [],
127-
ProjectLanguage: '',
128-
ProjectType: 'AspNetCoreMvc',
129-
ExternalReferences: [],
130-
}
131-
132-
// Add an unsupported project
133-
const unsupportedProjectMeta = {
134-
Name: 'Unsupported',
135-
ProjectTargetFramework: '',
136-
ProjectPath: 'unsupported.csproj',
137-
SourceCodeFilePaths: [],
138-
ProjectLanguage: '',
139-
ProjectType: 'UnsupportedType',
140-
ExternalReferences: [],
141-
}
142-
143-
// Add an AspNetWebForms project
144-
const webFormsProjectMeta = {
145-
Name: 'WebForms',
146-
ProjectTargetFramework: '',
147-
ProjectPath: 'webforms.csproj',
148-
SourceCodeFilePaths: [],
149-
ProjectLanguage: '',
150-
ProjectType: 'AspNetWebForms',
151-
ExternalReferences: [],
152-
}
153-
154-
mockStartTransformationRequest.ProjectMetadata = [
155-
supportedProjectMeta,
156-
unsupportedProjectMeta,
157-
webFormsProjectMeta,
158-
]
159-
160-
const unsupportedProjects = validateSolution(mockStartTransformationRequest)
161-
162-
// Should only contain the unsupported project, not the AspNetWebForms project
163-
expect(unsupportedProjects).to.have.lengthOf(1)
164-
expect(unsupportedProjects[0]).to.equal('unsupported.csproj')
165-
expect(unsupportedProjects).to.not.include('webforms.csproj')
166-
})
16799
})

0 commit comments

Comments
 (0)