All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
opencode_permission_listtool — lists all pending permission requests across sessions, showing permission type, session ID, patterns, and tool name. Helps detect and unblock sessions stuck waiting for approval in headless mode.OPENCODE_DEFAULT_PROVIDER/OPENCODE_DEFAULT_MODELenv vars — set default provider and model for all tool calls. Three-tier resolution: explicit params → env defaults → server fallback. Implemented viaapplyModelDefaults()across all 8 model-accepting tools.normalizeDirectory()path validation — resolves paths to absolute, strips trailing slashes, resolves.., and rejects non-existent directories with descriptive errors.- Lazy server reconnection — on
ECONNREFUSED/ENOTFOUNDafter all retries, auto-restarts the OpenCode server (max 3 reconnection attempts per MCP session). - Enhanced
diagnoseError()— 6 new error patterns with contextual suggestions (empty response, model errors, permission issues, config problems). - Directory display in workflow responses —
opencode_run,opencode_fire,opencode_check,opencode_statusnow show the active project directory. - Session-directory consistency warnings — warns when a session was created for a different directory than the current request.
- Permissions guidance in instructions — recommends
"permission": "allow"inopencode.jsonfor headless use, documents permission tools.
opencode_session_permissionupdated — now uses the new API (POST /permission/{requestID}/reply) with automatic fallback to the deprecated endpoint.replyparameter changed from free string to enum:"once"|"always"|"reject". Removed the oldrememberparameter.
- Directory validation errors swallowed by
.catch(() => null)—opencode_status,opencode_context, andopencode_checkusedPromise.allwith.catch(() => null)which silently ate validation errors (showing "UNREACHABLE" instead of "directory not found"). Fixed by adding earlynormalizeDirectory()beforePromise.allin all 3 tools.
- Demo projects (
projects/snake-game/,projects/nextjs-todo-app/) — these were test artifacts.
- Tool count: 79 (up from 78)
- Tests: 316 (up from 275)
opencode_runworkflow tool — one-call solution for complex tasks: creates a session, sends the prompt, polls until completion, and returns the result with todo progress. SupportsmaxDurationSeconds(default 10 min) and session reuse viasessionId.opencode_fireworkflow tool — fire-and-forget: creates a session, dispatches the task, and returns immediately with the session ID and monitoring instructions. Best for long-running tasks where you want to do other work in parallel.opencode_checkworkflow tool — compact progress report for a session: status, todo progress (completed/total), current task, file change count. Much cheaper thanopencode_conversation. Supportsdetailedmode for last message text.- Tool count: 78 (up from 75)
- Tests: 275 (up from 267) — 8 new tests covering
opencode_run(polling, error, session reuse),opencode_fire(dispatch, session reuse), andopencode_check(progress, completion, detailed mode)
- Instructions updated with new Tier 2 tools (
opencode_run,opencode_fire,opencode_check) and simplified recommended workflows - Best-practices prompt updated with new tool selection table
instructionsfield — the MCP server now provides a comprehensive structured guide via theinstructionsoption in theMcpServerconstructor. This helps LLM clients understand tool tiers (5 levels from essential to dangerous), recommended workflows, and the asyncmessage_send_async+waitpattern for long tasks.- Tool annotations — all tools now carry MCP
readOnlyHint/destructiveHintannotations so clients can auto-approve safe read-only operations and warn before destructive ones (e.g.session_delete,instance_dispose) opencode-best-practicesprompt — new prompt template (6th prompt) covering setup, provider/model selection, tool selection table, prompt writing tips, monitoring, error recovery, and common pitfalls- Honest wake-up documentation —
opencode_waitdescription now explains that most MCP clients do NOT interrupt the LLM for log notifications, and suggestsopencode_session_todofor monitoring very long tasks
opencode_instance_disposedescription now includes a WARNING about permanent shutdown- Prompts: 6 (up from 5)
- Tests: 267 (up from 266)
- Empty message display —
formatMessageList()no longer shows blank output for assistant messages that performed tool calls but had no text content. It now shows concise tool action summaries likeAgent performed 3 action(s): Write: /src/App.tsx, Bash: npm install - Session status
[object Object]—opencode_sessions_overviewandopencode_session_statusnow correctly resolve status objects (e.g.{ state: "running" }) to readable strings instead of displaying[object Object] opencode_waittimeout message — now includes actionable recovery suggestions (opencode_conversationto check progress,opencode_session_abortto stop) and correctly resolves object-shaped status values during pollingtoolError()contextual suggestions — common error patterns (401/403 auth, timeout, rate limit, connection refused, session not found) now include helpful follow-up tool suggestions instead of bare error text
resolveSessionStatus()exported helper insrc/helpers.ts— normalizes status from string, object ({ state, status, type }), or boolean flags into a readable stringsummarizeToolInput()helper — extracts the most useful arg (path, command, query, url) from tool input objects for compact displayextractCostMeta()helper — extracts cost/token metadata fromstep-finishmessage partsdiagnoseError()private helper — pattern-matches common errors and returns contextual suggestions- 11 new tool handler tests for
opencode_sessions_overview,opencode_session_status, andopencode_waitcovering object status resolution, timeout messages, and edge cases - Tests: 266 total (up from 255)
opencode_statusworkflow tool for a fast health/providers/sessions/VCS dashboardopencode_provider_testworkflow tool to quickly validate a provider/model actually responds (creates a temp session, sends a tiny prompt, cleans up)opencode_session_searchto find sessions by keyword in title (also matches session ID)scripts/mcp-smoke-test.mjsend-to-end smoke test runner (spawns opencode-mcp over stdio and exercises most tools/workflows against a running OpenCode server)
- Provider configuration detection is now shared via
isProviderConfigured()(used consistently across provider listing and setup workflows) - Multiple tool outputs are more token-efficient and user-friendly (compact provider list/model listing, session formatting, and warning surfacing)
- Tool count: 75 (up from 72)
- Tests: 255 total
opencode_message_sendno longer silently returns empty output for empty responses; it now appends actionable warnings likeopencode_ask/opencode_replyopencode_session_share/opencode_session_unsharenow return formatted confirmations instead of raw JSON dumpsopencode_events_pollno longer crashes on timeout when the SSE stream is idle (abort now cancels the stream safely)
- Auth error detection —
opencode_askandopencode_replynow analyze AI responses for signs of failure (empty response, missing text content, error keywords like "unauthorized" or "invalid key") and append a clear--- WARNING ---with actionable guidance instead of silently returning nothing analyzeMessageResponse()helper — new diagnostic function insrc/helpers.tsthat detects empty, error, and auth-related response issues- Provider probing in
opencode_setup— connected providers are now verified with a lightweight "Reply with OK" probe to distinguish between WORKING, CONNECTED BUT NOT RESPONDING (bad API key), and could-not-verify states. Unconfigured providers now show available auth methods. opencode_provider_modelstool — new tool to list models for a single provider, replacing the previous approach of dumping all providers and all models in one massive response- 164 tests (up from 140) — new tests for
analyzeMessageResponse, auth warning in ask/reply, provider probe statuses, compact provider list, and per-provider model listing
opencode_provider_listis now compact — returns only provider names, connection status, and model count (not the full model list). This dramatically reduces token usage for MCP clients. Useopencode_provider_modelswith a provider ID to drill into a specific provider's models.- Tool count: 72 (up from 71)
- Auto-serve — the MCP server now automatically detects whether
opencode serveis running and starts it as a child process if not. No more manual "start opencode serve" step before using the MCP server.- Checks the
/global/healthendpoint on startup - Finds the
opencodebinary viawhich/where - Spawns
opencode serve --port <port>and polls until healthy - Graceful shutdown: kills the managed child process on SIGINT/SIGTERM/exit
- Clear error messages with install instructions if the binary is not found
- Checks the
OPENCODE_AUTO_SERVEenv var — set to"false"to disable auto-start for users who prefer manual controlsrc/server-manager.tsmodule — new module withfindBinary(),isServerRunning(),startServer(),stopServer(),ensureServer()- 140 tests (up from 117) — 23 new tests for the server manager covering health checks, binary detection, auto-start, error cases, and shutdown
- Startup flow in
src/index.tsnow callsensureServer()before connecting the MCP transport - Updated README: removed manual "start opencode serve" step, added auto-serve documentation, updated env vars table and architecture section
- Per-tool project directory targeting — every tool now accepts an optional
directoryparameter that scopes the request to a specific project directory via thex-opencode-directoryheader. This enables working with multiple projects simultaneously from a single MCP connection without restarting the server. opencode_setupworkflow tool — new high-level onboarding tool that checks server health, lists provider configuration status, and shows project info. Use it as the first step when starting work.- 117 tests (up from 102) — new tests for directory header propagation,
opencode_setuphandler, anddirectoryParamvalidation
opencode_find_filetool: renamed the search-root override parameter fromdirectorytosearchDirectoryto avoid collision with the new project-scopingdirectoryparameter- Auth tools (
opencode_auth_set,opencode_provider_oauth_authorize,opencode_provider_oauth_callback) do not acceptdirectory— auth credentials are global, not project-scoped
- Test suite — 102 tests across 5 test files using Vitest
helpers.test.ts— 35 tests for all formatting and response helper functionsclient.test.ts— 37 tests for HTTP client, error handling, retry logic, authtools.test.ts— 16 tests for tool registration and handler behaviorresources.test.ts— 7 tests for MCP resource registration and handlersprompts.test.ts— 7 tests for MCP prompt registration and handlers
vitest.config.tsconfigurationtest,test:watch, andtest:coveragenpm scripts
- Removed opencode self-referencing config from README (it doesn't make sense to add opencode-mcp to opencode itself)
- Added MCP client configs for VS Code (GitHub Copilot), Cline, Continue, Zed, and Amazon Q
- Clarified that all environment variables and authentication are optional
- Added "Compatible MCP Clients" section to README
- Updated docs/configuration.md with all new client configs
- 70 MCP tools covering the entire OpenCode headless server API
- 7 high-level workflow tools —
opencode_ask,opencode_reply,opencode_conversation,opencode_sessions_overview,opencode_context,opencode_wait,opencode_review_changes - 18 session management tools — create, list, get, delete, update, fork, share, abort, revert, diff, summarize, permissions
- 6 message tools — send prompts (sync/async), list/get messages, slash commands, shell execution
- 6 file & search tools — text/regex search, file finder, symbol search, directory listing, file reading, VCS status
- 8 config & provider tools — configuration management, provider listing, auth (API keys, OAuth)
- 9 TUI control tools — remote-control the OpenCode TUI
- 13 system & monitoring tools — health, VCS, LSP, formatters, MCP servers, agents, commands, logging, events
- 10 MCP resources — browseable data endpoints for project, config, providers, agents, commands, health, VCS, sessions, MCP servers, file status
- 5 MCP prompts — guided workflow templates for code review, debugging, project setup, implementation, session summary
- Robust HTTP client — automatic retry with exponential backoff (429/502/503/504), error categorization, timeout support
- Smart response formatting — extracts meaningful text from message parts, truncation for large outputs
- SSE event polling — monitor real-time server events
npxsupport — run withnpx opencode-mcpwithout installing globally