Release On Quit
OpenCode TUI plugin that releases a project's cached MCP/LSP services when you quit, and sweeps every loaded location once the last OpenCode client exits.
4
+2 in 30 days
336
336 in 7 days
44.5
Multi-signal model
1 day ago
2026-10-04
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-release-on-quit@0.1.0"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-release-on-quit@0.1.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-release-on-quitOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
An OpenCode TUI plugin that shuts down what a project keeps running after you leave: when you quit a window it releases that project's cached services (MCP, LSP), and when the last OpenCode client exits it sweeps every loaded location — so no MCP processes stay alive overnight.
Community plugin. Not built by, endorsed by, or affiliated with the OpenCode team.
Why
OpenCode v2 keeps per-project MCP servers and LSPs warm inside its shared background service. Closing a session with /exit only closes the client: the project's cached services are not released at that point — they wait for an inactivity timer (the location layer currently uses a 60-minute idle TTL) or for a capacity/dispose mechanism, regardless of whether any client still has that project open. Over a day of opening several projects this can add up to gigabytes of processes you are no longer using.
This plugin makes /exit mean what you thought it meant: the project you leave is released once its client is gone, and when the last client exits nothing stays behind.
How it works
- When a TUI exits, the plugin spawns a small detached helper (
evict-deferred.mjs). - The helper waits until the TUI process is really gone — a dying client's last data syncs can undo an immediate release.
- It then disposes the cached services of that window's project via the server's location eviction API.
- If no other OpenCode client is running, it sweeps every loaded location.
Locations with a turn executing are never touched. Everything boots lazily again the next time you use it.
Requirements
- OpenCode
>= 2.0.0 - macOS or Linux (the helper uses
psto detect the last client) - Node.js available in
PATH(the deferred helper runs on it)
Install
Add it to your CLI configuration (~/.config/opencode/cli.json):
{
"plugins": ["opencode-release-on-quit"]
}
Or from the CLI:
opencode plugin add opencode-release-on-quit
Activity log
The helper appends a small log to ~/.local/share/opencode/release-on-quit.log:
2026-10-02T23:27:26.136Z start ppid=1 dirs=1
2026-10-02T23:27:26.204Z parent already gone at start
2026-10-02T23:27:27.800Z no other clients; sweeping all loaded locations
2026-10-02T23:27:27.900Z evicted: /Users/me/projects/app
2026-10-02T23:27:27.901Z done
Compatibility
- Uses the server's experimental
debug.location.evictendpoint. If a future OpenCode release removes or changes it, the helper logs the failure and nothing else happens — it fails soft. Known quirks of that endpoint are tracked upstream (for example, anomalyco/opencode#51198). - While other OpenCode clients stay open, a released location can be revived on demand by them. That is expected: the plugin never fights a live client.
Upstream
The permanent fix belongs in the service, not in a client plugin:
- anomalyco/opencode#53068 — feature request to release a project's cached services when its last client exits. This plugin is cited there as prior art; if it helps you, your experience in that thread is useful evidence.
- anomalyco/opencode#52946 — in-flight core work that caps the per-directory MCP instance cache (LRU).
Development
The package ships TypeScript source (src/); OpenCode's plugin runtime loads it directly.
npm install
npm run typecheck
npm run check:helper
To test locally through the plugin discovery directory, create a bridge at ~/.config/opencode/plugins/release-on-quit/tui.ts:
export { default } from "/absolute/path/to/opencode-release-on-quit/src/tui.ts"
Remove the bridge before switching to the published package, so the plugin does not load twice.
License
MIT
Similar plugins
Thatch
@jeffober/thatch
Persistent memory for AI coding agents — local embeddings, SQLite stores, zero config. Works with OpenCode (as a plugin), Claude Code (as an MCP server), and Cursor (as an MCP server).
@knowl/opencode
@knowl/opencode
Project memory for opencode, injected rather than requested. Retrieved knowledge reaches the system prompt, files carry their own recorded rules, and memory survives compaction.
Mempalace Persistence
opencode-mempalace-persistence
OpenCode plugin — auto-sync conversations to MemPalace memory in real-time. No forced wings, KG extraction via MCP tools.