Skip to content

Commit 2267cad

Browse files
authored
Revert "Merge pull request #1618 from aheizi/support_project_mcp" (#1784)
This reverts commit df80e96, reversing changes made to dc302f7.
1 parent 8b368e9 commit 2267cad

File tree

22 files changed

+60
-450
lines changed

22 files changed

+60
-450
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,28 +1183,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
11831183
}
11841184
break
11851185
}
1186-
case "openProjectMcpSettings": {
1187-
if (!vscode.workspace.workspaceFolders?.length) {
1188-
vscode.window.showErrorMessage(t("common:errors.no_workspace"))
1189-
return
1190-
}
1191-
1192-
const workspaceFolder = vscode.workspace.workspaceFolders[0]
1193-
const rooDir = path.join(workspaceFolder.uri.fsPath, ".roo")
1194-
const mcpPath = path.join(rooDir, "mcp.json")
1195-
1196-
try {
1197-
await fs.mkdir(rooDir, { recursive: true })
1198-
const exists = await fileExistsAtPath(mcpPath)
1199-
if (!exists) {
1200-
await fs.writeFile(mcpPath, JSON.stringify({ mcpServers: {} }, null, 2))
1201-
}
1202-
await openFile(mcpPath)
1203-
} catch (error) {
1204-
vscode.window.showErrorMessage(t("common:errors.create_mcp_json", { error }))
1205-
}
1206-
break
1207-
}
12081186
case "openCustomModesSettings": {
12091187
const customModesFilePath = await this.customModesManager.getCustomModesFilePath()
12101188
if (customModesFilePath) {

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,130 +2055,6 @@ describe("ClineProvider", () => {
20552055
})
20562056
})
20572057

2058-
describe("Project MCP Settings", () => {
2059-
let provider: ClineProvider
2060-
let mockContext: vscode.ExtensionContext
2061-
let mockOutputChannel: vscode.OutputChannel
2062-
let mockWebviewView: vscode.WebviewView
2063-
let mockPostMessage: jest.Mock
2064-
2065-
beforeEach(() => {
2066-
jest.clearAllMocks()
2067-
2068-
mockContext = {
2069-
extensionPath: "/test/path",
2070-
extensionUri: {} as vscode.Uri,
2071-
globalState: {
2072-
get: jest.fn(),
2073-
update: jest.fn(),
2074-
keys: jest.fn().mockReturnValue([]),
2075-
},
2076-
secrets: {
2077-
get: jest.fn(),
2078-
store: jest.fn(),
2079-
delete: jest.fn(),
2080-
},
2081-
subscriptions: [],
2082-
extension: {
2083-
packageJSON: { version: "1.0.0" },
2084-
},
2085-
globalStorageUri: {
2086-
fsPath: "/test/storage/path",
2087-
},
2088-
} as unknown as vscode.ExtensionContext
2089-
2090-
mockOutputChannel = {
2091-
appendLine: jest.fn(),
2092-
clear: jest.fn(),
2093-
dispose: jest.fn(),
2094-
} as unknown as vscode.OutputChannel
2095-
2096-
mockPostMessage = jest.fn()
2097-
mockWebviewView = {
2098-
webview: {
2099-
postMessage: mockPostMessage,
2100-
html: "",
2101-
options: {},
2102-
onDidReceiveMessage: jest.fn(),
2103-
asWebviewUri: jest.fn(),
2104-
},
2105-
visible: true,
2106-
onDidDispose: jest.fn(),
2107-
onDidChangeVisibility: jest.fn(),
2108-
} as unknown as vscode.WebviewView
2109-
2110-
provider = new ClineProvider(mockContext, mockOutputChannel)
2111-
})
2112-
2113-
test("handles openProjectMcpSettings message", async () => {
2114-
await provider.resolveWebviewView(mockWebviewView)
2115-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
2116-
2117-
// Mock workspace folders
2118-
;(vscode.workspace as any).workspaceFolders = [{ uri: { fsPath: "/test/workspace" } }]
2119-
2120-
// Mock fs functions
2121-
const fs = require("fs/promises")
2122-
fs.mkdir.mockResolvedValue(undefined)
2123-
fs.writeFile.mockResolvedValue(undefined)
2124-
2125-
// Trigger openProjectMcpSettings
2126-
await messageHandler({
2127-
type: "openProjectMcpSettings",
2128-
})
2129-
2130-
// Verify directory was created
2131-
expect(fs.mkdir).toHaveBeenCalledWith(
2132-
expect.stringContaining(".roo"),
2133-
expect.objectContaining({ recursive: true }),
2134-
)
2135-
2136-
// Verify file was created with default content
2137-
expect(fs.writeFile).toHaveBeenCalledWith(
2138-
expect.stringContaining("mcp.json"),
2139-
JSON.stringify({ mcpServers: {} }, null, 2),
2140-
)
2141-
})
2142-
2143-
test("handles openProjectMcpSettings when workspace is not open", async () => {
2144-
await provider.resolveWebviewView(mockWebviewView)
2145-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
2146-
2147-
// Mock no workspace folders
2148-
;(vscode.workspace as any).workspaceFolders = []
2149-
2150-
// Trigger openProjectMcpSettings
2151-
await messageHandler({
2152-
type: "openProjectMcpSettings",
2153-
})
2154-
2155-
// Verify error message was shown
2156-
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("Please open a project folder first")
2157-
})
2158-
2159-
test("handles openProjectMcpSettings file creation error", async () => {
2160-
await provider.resolveWebviewView(mockWebviewView)
2161-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
2162-
2163-
// Mock workspace folders
2164-
;(vscode.workspace as any).workspaceFolders = [{ uri: { fsPath: "/test/workspace" } }]
2165-
2166-
// Mock fs functions to fail
2167-
const fs = require("fs/promises")
2168-
fs.mkdir.mockRejectedValue(new Error("Failed to create directory"))
2169-
2170-
// Trigger openProjectMcpSettings
2171-
await messageHandler({
2172-
type: "openProjectMcpSettings",
2173-
})
2174-
2175-
// Verify error message was shown
2176-
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith(
2177-
expect.stringContaining("Failed to create or open .roo/mcp.json"),
2178-
)
2179-
})
2180-
})
2181-
21822058
describe("ContextProxy integration", () => {
21832059
let provider: ClineProvider
21842060
let mockContext: vscode.ExtensionContext

0 commit comments

Comments
 (0)