Skip to content

Commit f98676e

Browse files
authored
fix: Enhance MCP download function to support local MCP retrieval (#191)
1 parent 38c1992 commit f98676e

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

.changeset/fast-baboons-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hai-build-code-generator": patch
3+
---
4+
5+
The MCP install function now supports local MCPs in addition to remote sources, improving flexibility.

src/core/controller/mcp/downloadMcp.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getLocalMcpDetails, isLocalMcp } from "@/utils/local-mcp-registry"
12
import { Controller } from ".."
23
import { Empty, StringRequest } from "../../../shared/proto/common"
34
import { McpServer, McpDownloadResponse } from "@shared/mcp"
@@ -22,28 +23,35 @@ export async function downloadMcp(controller: Controller, request: StringRequest
2223
// Check if we already have this MCP server installed
2324
const servers = controller.mcpHub?.getServers() || []
2425
const isInstalled = servers.some((server: McpServer) => server.name === mcpId)
26+
let mcpDetails: McpDownloadResponse
2527

2628
if (isInstalled) {
2729
throw new Error("This MCP server is already installed")
2830
}
2931

30-
// Fetch server details from marketplace
31-
const response = await axios.post<McpDownloadResponse>(
32-
"https://api.cline.bot/v1/mcp/download",
33-
{ mcpId },
34-
{
35-
headers: { "Content-Type": "application/json" },
36-
timeout: 10000,
37-
},
38-
)
39-
40-
if (!response.data) {
41-
throw new Error("Invalid response from MCP marketplace API")
42-
}
32+
// Check if this is a local MCP
33+
if (isLocalMcp(mcpId)) {
34+
// Get details from local registry
35+
mcpDetails = await getLocalMcpDetails(mcpId)
36+
console.log("[downloadMcp] Using local data for MCP server", { mcpDetails })
37+
} else {
38+
// Fetch server details from marketplace
39+
const response = await axios.post<McpDownloadResponse>(
40+
"https://api.cline.bot/v1/mcp/download",
41+
{ mcpId },
42+
{
43+
headers: { "Content-Type": "application/json" },
44+
timeout: 10000,
45+
},
46+
)
47+
if (!response.data) {
48+
throw new Error("Invalid response from MCP marketplace API")
49+
}
4350

44-
console.log("[downloadMcp] Response from download API", { response })
51+
console.log("[downloadMcp] Response from download API", { response })
4552

46-
const mcpDetails = response.data
53+
mcpDetails = response.data
54+
}
4755

4856
// Validate required fields
4957
if (!mcpDetails.githubUrl) {

0 commit comments

Comments
 (0)