Skip to content

bug: /mcp add on the first-ever MCP server fails to log in with "No MCP servers configured." #910

Description

@mabaeyens

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

  1. Start vibe in a project/user config with no [[mcp_servers]] entries.
  2. Run /mcp add https://example.com/mcp --name my-server --scope read --transport streamable-http.
  3. Observe: "Added OAuth MCP server my-server. Starting OAuth login..." followed by "Error: No MCP servers configured."
  4. Run /mcp status — also reports "No MCP servers configured." in the same session.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions