Repository navigation
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Summary
When opencode runs as an ACP agent (e.g. Zed), the client cannot authenticate or re-authenticate opencode's native MCP servers. OAuth servers can only be signed in from a terminal (opencode mcp auth <name>) or the TUI (/mcps). With short-lived OAuth sessions this means re-login outside the client on every expiry.
Environment
- opencode: 2.0.27 (release/latest)
- OS: Linux 7.0.0-38-generic (x64)
- Client: Zed (custom
agent_servers,opencode acp); TERM=xterm-256color - Shell: /usr/bin/zsh
- Plugins: local (
~/.config/opencode/plugins/: attention.js, knowledge-capture.js, session-branch.js)
Reproduction
- Add a remote OAuth MCP server to
mcp.servers. - Open opencode from Zed (ACP).
opencode mcp listshowsneeds authentication; the client offers no way to sign in. - Log in once from a terminal, then use the agent until the OAuth session expires — refresh is rejected, the credential is invalidated, MCP calls return 401, and there is still no in-client way to re-authorize.
Expected Behavior
The ACP client can trigger MCP auth/re-auth, similar to provider login over ACP.
Actual Behavior
Only opencode-login (provider auth) is advertised. MCP OAuth servers require a browser flow reachable only outside the client. On invalid_grant opencode invalidates the credential and the client just keeps getting 401s with no actionable prompt.
mcp oauth authorization completed hasRefreshToken=true expiresIn=400
mcp oauth request rejected error=invalid_grant
message="Refresh session expired by policy. Please re-authorize via OAuth."
mcp oauth credential invalidated scope=tokens
Additional Context
-
Client-forwarded MCP servers (
session/newmcpServers) don't use OAuth (headers only), so Zed'scontext_serverscan't substitute for opencode's native OAuth servers. -
Proposed:
(1) expose servers needing auth via ACPauthenticateas terminal methods (args: ["mcp","auth","<name>"]);
(2) send a session update when re-auth is needed; (3) expose an MCP command viaavailable_commands_update. -
Consistently reproducible; in the reported setup re-auth was needed ~8 min after login.
Activity
opencode-agent commentedon Oct 13, 2026
Thanks for the detailed request, @monrus!
To restate it: when opencode runs as an ACP agent (e.g. in Zed), you'd like the client to be able to start authentication or re-authentication for opencode's native OAuth MCP servers. Right now that's only possible from a terminal (
opencode mcp auth <name>) or the TUI (/mcps). You also want a clear prompt when re-auth is needed, instead of repeated 401s. That matches the current code: over ACP, opencode only advertises the provider login method (opencode-login).Maintainers will consider this along with your proposed approaches (per-server terminal auth methods, a re-auth session update, and an MCP command via
available_commands_update). A plugin can't do this today, because plugins have no access to ACP auth methods or session updates.These are related but don't cover this request: