feat(config): add mcp_inherit flag to control global MCP inheritance#28900
Open
herjarsa wants to merge 9 commits into
Open
feat(config): add mcp_inherit flag to control global MCP inheritance#28900herjarsa wants to merge 9 commits into
herjarsa wants to merge 9 commits into
Conversation
- Checkpoint WAL before closing to prevent corruption on crash - Wrap PRAGMA journal_mode=WAL in try-catch with fallback to DELETE mode - Fixes crash on open when WAL is in inconsistent state from previous crash
- Add SIGTERM handler in exit.tsx alongside existing SIGHUP handler - Add SIGTERM handler in thread.ts to gracefully stop worker - Add Effect.ensuring to abort AbortController in prompt.ts execRead - Replace unbounded Map with LRU cache in instance.ts (max 20 entries) Fixes anomalyco#15348 This addresses the critical issue where: 1. Processes spawned by opencode on Linux become orphaned when terminal closes 2. AbortController instances accumulate in session prompts causing heap growth 3. Instance cache grows without bound holding references to contexts Closes anomalyco#15348
Apply LRU cache and cleanup logic from PRs anomalyco#9141 and anomalyco#16346: - Add createLruCache utility with maxEntries: 20 - Replace unbounded Map in instance.ts with LRU cache - Clear LSP diagnostics maps and file entries on shutdown - Clean up LSP clients/broken/spawning on teardown Fixes: anomalyco#12513 (200% CPU + 92.5GB memory on empty session)
fix(storage): add WAL checkpoint on close and fallback for corrupted WAL
fix(memory): prevent unbounded cache growth causing 92GB leak (closes anomalyco#12513)
…t_id not in stream When filterCompacted encounters a compaction part with tail_start_id pointing to a message older than available history, it previously included ALL messages in the result, causing context to inflate to 1.7M tokens instead of ~161k. This fix: 1. Tracks all messages in an 'all' array during iteration 2. When retain is set but not found, returns only the recent messages after retain was encountered (all.slice(-result.length)), not everything 3. Adds safety check in compaction.ts to skip overflow mode when selected.head is empty (which indicates tail_start_id is not in available history) Fixes anomalyco#24249
fix(session): prevent context inflation to 1.7M tokens when tail_start_id not in stream
Adds a mcp_inherit config field (defaults to true) that lets projects opt out of inheriting global MCP servers. When set to false, only MCP servers defined in project/local config are loaded. Also tracks mcp_provenance (derived state) to show origin scope in the CLI: 'opencode mcp list' now displays (global) or (local) tags. This solves the workflow of having many MCPs globally available without needing to manually disable them per project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Improves MCP server management workflow — no related issue.
Type of change
What does this PR do?
Adds a
mcp_inheritconfig field (defaults totrue) that lets projects opt out of inheriting global MCP servers. Currently every project inherits all globally configured MCPs, and disabling them per-server is tedious. This field gives a clean escape hatch.When
mcp_inherit: falseis set in project-levelopencode.jsonc, the config layer skips merging global MCP entries — only servers defined locally (project or.opencode/) survive. The existing behavior is unchanged when the field is omitted.Also adds
mcp_provenancederived state (likeplugin_origins) so the CLI and UI can show where each server came from. Theopencode mcp listcommand now displays(global)or(local)tags.How did you verify your code works?
lsp_diagnosticson both modified files — zero errorsScreenshots / recordings
N/A — config layer change, no UI.
Checklist