Open readme preview for mcp servers

This commit is contained in:
Saoud Rizwan committed 2025-02-15 15:23:15 -08:00
1 parent 0cbd6b321f
commit faae5f22a3
3 files changed
+43

No files matched your search

+32
View File
@@ -29,6 +29,7 @@ import { getUri } from "./getUri"
import { AutoApprovalSettings, DEFAULT_AUTO_APPROVAL_SETTINGS } from "../../shared/AutoApprovalSettings"
import { BrowserSettings, DEFAULT_BROWSER_SETTINGS } from "../../shared/BrowserSettings"
import { ChatSettings, DEFAULT_CHAT_SETTINGS } from "../../shared/ChatSettings"
import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider"
/*
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -928,6 +929,37 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
break
}
case "openMcpMarketplaceServerDetails": {
if (message.mcpId) {
// close existing
const tabs = vscode.window.tabGroups.all
.flatMap((tg) => tg.tabs)
.filter((tab) => tab.label && tab.label.includes("README") && tab.label.includes("Preview"))
for (const tab of tabs) {
await vscode.window.tabGroups.close(tab)
}
const response = await fetch(`https://api.cline.bot/v1/mcp/marketplace/item?mcpId=${message.mcpId}`)
const details: McpDownloadResponse = await response.json()
if (details.readmeContent) {
// Create URI with base64 encoded markdown content
const uri = vscode.Uri.parse(
`${DIFF_VIEW_URI_SCHEME}:${details.name} README?${Buffer.from(details.readmeContent).toString("base64")}`,
)
// Show only the preview
await vscode.commands.executeCommand("markdown.showPreview", uri, {
sideBySide: true,
preserveFocus: true,
})
}
}
this.postMessageToWebview({ type: "relinquishControl" })
break
}
case "toggleMcpServer": {
try {
await this.mcpHub?.toggleServerDisabled(message.serverName!, message.disabled!)
+1
View File
@@ -45,6 +45,7 @@ export interface WebviewMessage {
| "subscribeEmail"
| "fetchMcpMarketplace"
| "downloadMcp"
| "openMcpMarketplaceServerDetails"
// | "relaunchChromeDebugMode"
text?: string
disabled?: boolean