1+ import { getLocalMcpDetails , isLocalMcp } from "@/utils/local-mcp-registry"
12import { Controller } from ".."
23import { Empty , StringRequest } from "../../../shared/proto/common"
34import { 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