Skip to content

Commit 60c7277

Browse files
committed
refactor: add types
1 parent 5a27679 commit 60c7277

27 files changed

+532
-414
lines changed

.luarc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"diagnostics.disable": [
33
"different-requires"
4+
],
5+
"diagnostics.globals": [
6+
"vim",
7+
"lvim",
8+
"reload",
9+
"MiniTest"
410
]
511
}

lua/mcphub/config.lua

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
local M = {}
2+
3+
local SHUTDOWN_DELAY = 10 * 60 * 1000 -- 10 minutes
4+
5+
---@class MCPHub.Config
6+
local defaults = {
7+
port = 37373, -- Default port for MCP Hub
8+
server_url = nil, -- In cases where mcp-hub is hosted somewhere, set this to the server URL e.g `http://mydomain.com:customport` or `https://url_without_need_for_port.com`
9+
config = vim.fn.expand("~/.config/mcphub/servers.json"), -- Default config location
10+
shutdown_delay = SHUTDOWN_DELAY, -- Delay before shutting down the mcp-hub
11+
---@type table<string, NativeServerDef>
12+
native_servers = {},
13+
auto_approve = false,
14+
auto_toggle_mcp_servers = true, -- Let LLMs start and stop MCP servers automatically
15+
use_bundled_binary = false, -- Whether to use bundled mcp-hub binary
16+
---@type string?
17+
cmd = nil, -- will be set based on system if not provided
18+
---@type table?
19+
cmdArgs = nil, -- will be set based on system if not provided
20+
---@type LogConfig
21+
log = {
22+
level = vim.log.levels.ERROR,
23+
to_file = false,
24+
file_path = nil,
25+
prefix = "MCPHub",
26+
},
27+
---@type MCPHub.UIConfig
28+
ui = {
29+
window = {
30+
width = 0.85, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
31+
height = 0.85, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
32+
border = "rounded", -- "none", "single", "double", "rounded", "solid", "shadow"
33+
relative = "editor",
34+
zindex = 50,
35+
},
36+
},
37+
extensions = {
38+
avante = {
39+
enabled = true,
40+
make_slash_commands = true,
41+
},
42+
},
43+
on_ready = function() end,
44+
---@param msg string
45+
on_error = function(msg) end,
46+
}
47+
48+
---@param opts MCPHub.Config?
49+
---@return MCPHub.Config
50+
function M.setup(opts)
51+
M.config = vim.tbl_deep_extend("force", defaults, opts or {})
52+
return M.config
53+
end
54+
55+
return setmetatable(M, {
56+
__index = function(_, key)
57+
if key == "setup" then
58+
return M.setup
59+
end
60+
return rawget(M.config, key)
61+
end,
62+
})

lua/mcphub/health.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---@diagnostic disable: deprecated
12
local start = vim.health.start or vim.health.report_start --[[@as function]]
23
local ok = vim.health.ok or vim.health.report_ok --[[@as function]]
34
local info = vim.health.info or vim.health.report_info --[[@as function]]

0 commit comments

Comments
 (0)