Skip to content

Commit d509598

Browse files
committed
fix: seperate the installation script
fix: dont format
1 parent ab89f6c commit d509598

3 files changed

Lines changed: 56 additions & 55 deletions

File tree

bundled_build.lua

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,5 @@ else
7878
error("Failed to install mcp-hub: " .. npm_install_result.stderr)
7979
end
8080

81-
status("Installing RPC proxy dependencies...", vim.log.levels.INFO)
82-
local proxy_install_result = vim.system({
83-
"npm",
84-
"install",
85-
}, {
86-
cwd = root .. "/scripts",
87-
stdout = on_stdout,
88-
stderr = on_stderr,
89-
}):wait()
90-
if proxy_install_result.code ~= 0 then
91-
status(
92-
"Warning: Failed to install RPC proxy dependencies: " .. proxy_install_result.stderr,
93-
vim.log.levels.WARN
94-
)
95-
else
96-
status("RPC proxy dependencies installed successfully", vim.log.levels.INFO)
97-
end
98-
9981
status("Build complete!", vim.log.levels.INFO)
10082
end

bundled_scripts.lua

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- Get plugin root directory
2+
---@return string
3+
local function get_root()
4+
return vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
5+
end
6+
7+
---@param msg string
8+
---@param level? number default: TRACE
9+
local function status(msg, level)
10+
vim.schedule(function()
11+
print(msg)
12+
--INFO: This is not working as expected
13+
-- coroutine.yield({
14+
-- msg = msg,
15+
-- level = level or vim.log.levels.TRACE,
16+
-- })
17+
end)
18+
end
19+
20+
local root = get_root()
21+
22+
local function on_stdout(err, data)
23+
if data then
24+
status(data, vim.log.levels.INFO)
25+
end
26+
if err then
27+
status(err, vim.log.levels.ERROR)
28+
end
29+
end
30+
31+
local function on_stderr(err, data)
32+
if data then
33+
status(data, vim.log.levels.ERROR)
34+
end
35+
if err then
36+
status(err, vim.log.levels.ERROR)
37+
end
38+
end
39+
40+
status("Installing bundled script dependencies...", vim.log.levels.INFO)
41+
local result = vim.system({
42+
"npm",
43+
"install",
44+
}, {
45+
cwd = root .. "/scripts",
46+
stdout = on_stdout,
47+
stderr = on_stderr,
48+
}):wait()
49+
if result.code ~= 0 then
50+
status("Warning: Failed to install RPC proxy dependencies: " .. result.stderr, vim.log.levels.WARN)
51+
else
52+
status("RPC proxy dependencies installed successfully", vim.log.levels.INFO)
53+
end
54+
55+
status("Build complete!", vim.log.levels.INFO)

lua/mcphub/extensions/proxy/init.lua

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,43 +49,7 @@ function M.get_all_servers()
4949
return {}
5050
end
5151

52-
local servers = hub:get_servers()
53-
54-
local formatted_servers = {}
55-
for _, server in ipairs(servers) do
56-
table.insert(formatted_servers, {
57-
name = server.name,
58-
displayName = server.displayName,
59-
description = server.description,
60-
status = server.status,
61-
capabilities = {
62-
tools = vim.tbl_map(function(t)
63-
return {
64-
name = t.name,
65-
description = t.description,
66-
inputSchema = t.inputSchema,
67-
}
68-
end, server.capabilities.tools or {}),
69-
resources = vim.tbl_map(function(r)
70-
return {
71-
uri = r.uri,
72-
name = r.name,
73-
description = r.description,
74-
mimeType = r.mimeType,
75-
}
76-
end, server.capabilities.resources or {}),
77-
prompts = vim.tbl_map(function(p)
78-
return {
79-
name = p.name,
80-
description = p.description,
81-
arguments = p.arguments,
82-
}
83-
end, server.capabilities.prompts or {}),
84-
},
85-
})
86-
end
87-
88-
return formatted_servers
52+
return hub:get_servers()
8953
end
9054

9155
--- Send result back to proxy.js via notification

0 commit comments

Comments
 (0)