Skip to content

Commit cf0af8a

Browse files
celestial-vaultElephant Lumps
andauthored
Migrate openMcpSettings protobus (RooCodeInc#3778)
* migrate openMcpSettings * changeset --------- Co-authored-by: Elephant Lumps <[email protected]>
1 parent b9551c9 commit cf0af8a

File tree

8 files changed

+34
-15
lines changed

8 files changed

+34
-15
lines changed

.changeset/popular-wombats-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Migrate openMcpSettings to protobus

proto/mcp.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ service McpService {
1515
rpc deleteMcpServer(StringRequest) returns (McpServers);
1616
rpc toggleToolAutoApprove(ToggleToolAutoApproveRequest) returns (McpServers);
1717
rpc refreshMcpMarketplace(EmptyRequest) returns (McpMarketplaceCatalog);
18+
rpc openMcpSettings(EmptyRequest) returns (Empty);
1819
}
1920

2021
message ToggleMcpServerRequest {

src/core/controller/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,6 @@ export class Controller {
316316
await this.fetchUserCreditsData()
317317
break
318318
}
319-
case "openMcpSettings": {
320-
const mcpSettingsFilePath = await this.mcpHub?.getMcpSettingsFilePath()
321-
if (mcpSettingsFilePath) {
322-
await handleFileServiceRequest(this, "openFile", { value: mcpSettingsFilePath })
323-
}
324-
break
325-
}
326319
case "fetchMcpMarketplace": {
327320
await this.fetchMcpMarketplace(message.bool)
328321
break
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Controller } from ".."
2+
import { Empty, EmptyRequest } from "@shared/proto/common"
3+
import { openFile as openFileIntegration } from "@integrations/misc/open-file"
4+
5+
/**
6+
* Opens the MCP settings file in the editor
7+
* @param controller The controller instance
8+
* @param _request Empty request
9+
* @returns Empty response
10+
*/
11+
export async function openMcpSettings(controller: Controller, _request: EmptyRequest): Promise<Empty> {
12+
const mcpSettingsFilePath = await controller.mcpHub?.getMcpSettingsFilePath()
13+
if (mcpSettingsFilePath) {
14+
await openFileIntegration(mcpSettingsFilePath)
15+
}
16+
return Empty.create()
17+
}

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface WebviewMessage {
1515
| "reportBug"
1616
| "openInBrowser"
1717
| "showChatView"
18-
| "openMcpSettings"
1918
| "openExtensionSettings"
2019
| "requestVsCodeLmModels"
2120
| "showAccountViewClicked"

webview-ui/src/components/mcp/configuration/tabs/add-server/AddLocalServerForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
2-
import { vscode } from "@/utils/vscode"
32
import styled from "styled-components"
43
import { LINKS } from "@/constants"
4+
import { McpServiceClient } from "@/services/grpc-client"
55

66
type AddLocalServerFormProps = {
77
onServerAdded: () => void
@@ -22,7 +22,9 @@ const AddLocalServerForm = ({ onServerAdded }: AddLocalServerFormProps) => {
2222
appearance="primary"
2323
style={{ width: "100%", marginBottom: "5px", marginTop: 8 }}
2424
onClick={() => {
25-
vscode.postMessage({ type: "openMcpSettings" })
25+
McpServiceClient.openMcpSettings({}).catch((error) => {
26+
console.error("Error opening MCP settings:", error)
27+
})
2628
}}>
2729
Open cline_mcp_settings.json
2830
</VSCodeButton>

webview-ui/src/components/mcp/configuration/tabs/add-server/AddRemoteServerForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useRef, useState } from "react"
2-
import { vscode } from "@/utils/vscode"
32
import { VSCodeButton, VSCodeLink, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
43
import { LINKS } from "@/constants"
54
import { McpServiceClient } from "@/services/grpc-client"
@@ -116,7 +115,9 @@ const AddRemoteServerForm = ({ onServerAdded }: { onServerAdded: () => void }) =
116115
appearance="secondary"
117116
style={{ width: "100%", marginBottom: "5px", marginTop: 15 }}
118117
onClick={() => {
119-
vscode.postMessage({ type: "openMcpSettings" })
118+
McpServiceClient.openMcpSettings({}).catch((error) => {
119+
console.error("Error opening MCP settings:", error)
120+
})
120121
}}>
121122
Edit Configuration
122123
</VSCodeButton>

webview-ui/src/components/mcp/configuration/tabs/installed/InstalledServersView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
2-
import { vscode } from "@/utils/vscode"
32
import { useExtensionState } from "@/context/ExtensionStateContext"
43

5-
import { UiServiceClient } from "@/services/grpc-client"
4+
import { UiServiceClient, McpServiceClient } from "@/services/grpc-client"
65

76
import ServersToggleList from "./ServersToggleList"
87
const InstalledServersView = () => {
@@ -40,7 +39,9 @@ const InstalledServersView = () => {
4039
appearance="secondary"
4140
style={{ width: "100%", marginBottom: "5px" }}
4241
onClick={() => {
43-
vscode.postMessage({ type: "openMcpSettings" })
42+
McpServiceClient.openMcpSettings({}).catch((error) => {
43+
console.error("Error opening MCP settings:", error)
44+
})
4445
}}>
4546
<span className="codicon codicon-server" style={{ marginRight: "6px" }}></span>
4647
Configure MCP Servers

0 commit comments

Comments
 (0)