Skip to content

Native MCP servers not started on initial hub startup #260

@ckang2-atlassian

Description

@ckang2-atlassian

Environment:

  • mcphub.nvim version: [latest from main branch]
  • Neovim version: 0.11.5
  • OS: macOS

Description:
Native MCP servers (particularly the neovim server) are not automatically started when MCPHub initializes. They remain in "disconnected" status until a configuration file change event occurs.

Steps to Reproduce:

  1. Start Neovim with mcphub.nvim configured
  2. Open CodeCompanion (or check :lua vim.print(require('mcphub.state').server_state.native_servers))
  3. Observe that native servers have status = "disconnected" initially
  4. Wait for a config file change OR manually toggle a server
  5. Native servers then transition to status = "connected"

Expected Behavior:
Native servers should be status = "connected" immediately when the hub becomes ready, since they don't require external processes to start.

Root Cause:
In lua/mcphub/hub.lua, the handle_hub_ready() function (line ~435) calls:

  • self:update_servers() - which only updates external MCP servers
  • But does NOT call self:refresh_native_servers() - which starts native servers

Native servers only get started when:

  1. reload_config() is called (triggered by CONFIG_CHANGED SSE event)
  2. Which then calls refresh_native_servers()

Proposed Fix:
Add self:refresh_native_servers() to handle_hub_ready():

function MCPHub:handle_hub_ready()
    self.ready = true
    self.is_restarting = false
    self.is_starting = false
    self:_update_global_state()
    self.on_ready(self)
    -- Start native servers on initial hub ready
    self:refresh_native_servers()  -- ADD THIS LINE
    self:update_servers()
    if State.marketplace_state.status == "empty" then
        self:get_marketplace_catalog()
    end
end

Impact:
This bug significantly affects user experience with chat integrations (CodeCompanion, Avante, CopilotChat) as the native Neovim tools that provide file operations are not available immediately, causing initial tool calls to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions