Description
Running /mcp add <url> --scope ... --transport streamable-http to add the first MCP server in a running session persists the server correctly to config.toml, but the immediate OAuth login step fails:
Added OAuth MCP server my-server.
Starting OAuth login...
Error: No MCP servers configured.
config.toml is written correctly (verified with tomllib.load), and restarting Vibe then running /mcp login my-server works fine. The bug only affects the very first MCP server added to a session that started with zero configured servers.
Root cause
The interactive TUI constructs AgentLoop with defer_heavy_init=True (vibe/cli/cli.py:341). With that flag, mcp_registry stays None until _ensure_remote_registries() runs once during deferred init (_complete_init, vibe/core/agent_loop/_loop.py), and that method only creates the registry if self.mcp_registry is None and self.config.mcp_servers — i.e. only if servers already existed at startup.
/mcp add (vibe/cli/textual_ui/app.py::_mcp_add) persists the new server and calls AgentLoop.refresh_config(), but refresh_config() only does:
if self.mcp_registry is not None:
self.mcp_registry.sync_active_servers(self.config.mcp_servers)
Since mcp_registry was None before this first server existed, it stays None forever in that session — refresh_config() never calls _ensure_remote_registries() to lazily create it. The subsequent _mcp_login call then sees self.agent_loop.mcp_registry is None and reports "No MCP servers configured.", even though the server is genuinely configured on disk.
Steps to reproduce
- Start
vibe in a project/user config with no [[mcp_servers]] entries.
- Run
/mcp add https://example.com/mcp --name my-server --scope read --transport streamable-http.
- Observe: "Added OAuth MCP server
my-server. Starting OAuth login..." followed by "Error: No MCP servers configured."
- Run
/mcp status — also reports "No MCP servers configured." in the same session.
- Exit and restart
vibe. Run /mcp login my-server — works correctly.
Expected behavior
/mcp add's automatic login (and any following /mcp login//mcp status) should work in the same session the server was added in, without requiring a restart.
Actual behavior
/mcp login and /mcp status report Error: No MCP servers configured. in the same session the first server was added, even though config.toml already contains the new [[mcp_servers]] entry on disk. The condition only clears after restarting Vibe.
Environment
vibe --version: 2.19.0 (also present on main as of the v2.20.0 tag)
- Python version: 3.12
- OS: macOS
Error messages
Added OAuth MCP server my-server.
Starting OAuth login...
Error: No MCP servers configured.
Configuration
Reproducible with a minimal config.toml that has no [[mcp_servers]] entries at session start (the bug is specific to the empty-to-first-server transition, not to any particular server's settings). Example server entry added via /mcp add:
[[mcp_servers]]
name = "my-server"
url = "https://example.com/mcp"
transport = "streamable-http"
scope = "read"
I have a minimal fix + regression test ready — see linked PR #911.
Description
Running
/mcp add <url> --scope ... --transport streamable-httpto add the first MCP server in a running session persists the server correctly toconfig.toml, but the immediate OAuth login step fails:config.tomlis written correctly (verified withtomllib.load), and restarting Vibe then running/mcp login my-serverworks fine. The bug only affects the very first MCP server added to a session that started with zero configured servers.Root cause
The interactive TUI constructs
AgentLoopwithdefer_heavy_init=True(vibe/cli/cli.py:341). With that flag,mcp_registrystaysNoneuntil_ensure_remote_registries()runs once during deferred init (_complete_init,vibe/core/agent_loop/_loop.py), and that method only creates the registryif self.mcp_registry is None and self.config.mcp_servers— i.e. only if servers already existed at startup./mcp add(vibe/cli/textual_ui/app.py::_mcp_add) persists the new server and callsAgentLoop.refresh_config(), butrefresh_config()only does:Since
mcp_registrywasNonebefore this first server existed, it staysNoneforever in that session —refresh_config()never calls_ensure_remote_registries()to lazily create it. The subsequent_mcp_logincall then seesself.agent_loop.mcp_registry is Noneand reports "No MCP servers configured.", even though the server is genuinely configured on disk.Steps to reproduce
vibein a project/user config with no[[mcp_servers]]entries./mcp add https://example.com/mcp --name my-server --scope read --transport streamable-http.my-server. Starting OAuth login..." followed by "Error: No MCP servers configured."/mcp status— also reports "No MCP servers configured." in the same session.vibe. Run/mcp login my-server— works correctly.Expected behavior
/mcp add's automatic login (and any following/mcp login//mcp status) should work in the same session the server was added in, without requiring a restart.Actual behavior
/mcp loginand/mcp statusreportError: No MCP servers configured.in the same session the first server was added, even thoughconfig.tomlalready contains the new[[mcp_servers]]entry on disk. The condition only clears after restarting Vibe.Environment
vibe --version: 2.19.0 (also present on main as of thev2.20.0tag)Error messages
Configuration
Reproducible with a minimal
config.tomlthat has no[[mcp_servers]]entries at session start (the bug is specific to the empty-to-first-server transition, not to any particular server's settings). Example server entry added via/mcp add:I have a minimal fix + regression test ready — see linked PR #911.