Problem
When a remote MCP fails to connect with UnauthorizedError, opencode sets its status to needs_auth and surfaces a toast pointing at the /mcps picker (or the opencode mcp auth shell subcommand). However, the running agent has zero awareness that this MCP exists:
MCP.tools() filters to status === "connected" clients only, so no tool from a needs_auth MCP reaches the agent's tool list.
- The system prompt does not enumerate configured MCPs.
- The agent therefore cannot reason about the MCP, cannot suggest authentication, and cannot trigger the OAuth flow on the user's behalf.
A user asking "use the mops-integration MCP and list rentals for X" gets a generic "I don't have that tool" response, with no path forward inside the conversation.
Expected behaviour
The agent should know which MCPs are configured-but-unauthenticated and have a way to trigger the OAuth flow when the user asks.
Reproduction
- Configure a remote MCP with OAuth (e.g. any Keycloak-backed MCP).
- Clear its tokens (delete
tokens from ~/.local/share/opencode/mcp-auth.json for that MCP) and restart opencode.
- Ask the agent: "use to ".
- The agent reports it doesn't have any tools matching
<name>.
Environment
- opencode 1.14.48 (also reproduces against current
dev HEAD).
- Any remote MCP with OAuth that returns
UnauthorizedError on connect.
Related
Problem
When a remote MCP fails to connect with
UnauthorizedError, opencode sets its status toneeds_authand surfaces a toast pointing at the/mcpspicker (or theopencode mcp authshell subcommand). However, the running agent has zero awareness that this MCP exists:MCP.tools()filters tostatus === "connected"clients only, so no tool from aneeds_authMCP reaches the agent's tool list.A user asking "use the mops-integration MCP and list rentals for X" gets a generic "I don't have that tool" response, with no path forward inside the conversation.
Expected behaviour
The agent should know which MCPs are configured-but-unauthenticated and have a way to trigger the OAuth flow when the user asks.
Reproduction
tokensfrom~/.local/share/opencode/mcp-auth.jsonfor that MCP) and restart opencode.<name>.Environment
devHEAD).UnauthorizedErroron connect.Related