Repository navigation
fix(mcp): keep bare OpenCode server-prefix tool keys across import and generate - #3740
Merged
Merged
Conversation
…d generate A `tools` key that is exactly a listed server's sanitized `<server>_` prefix is still left out on import, but OpenCode-family generate now carries it over from the existing config so a deny it holds is not lost on an import -> generate round trip. Kilo's orphan pass now skips keys a listed server owns under its sanitized name and bare prefixes, so it no longer imports phantom orphan servers. The bare-prefix check lives in a shared isBareOpencodeMcpServerPrefix helper, and the docs note covers OpenCode V1 / MiMo Code and the bare-prefix behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
A bare `<server>_` key that another listed server owns (`a_b_` is tool `b_` of server `a`) is the rulesync config's to write, so generate no longer carries it over from the existing file; otherwise a removed filter could never be dropped. Warn when an existing config that fails the schema holds a bare key that cannot be kept, and document both limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
Select warned keys the same way preserveBareOpencodeMcpServerPrefixKeys selects kept ones, so a bare key another listed server owns is not reported as "not kept" when it would never be carried over anyway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth
Merged
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.
Summary
Follow-ups to #3727 for OpenCode-family MCP
toolskeys that are exactly a listed server's sanitized<server>_prefix (e.g.a_b_for servera.b/a_b).a/b_), andgeneratenow carries it over from the existingopencode.json(c)unless a generated filter already writes the same key. Soa_b_: falsesurvivesrulesync import→generateinstead of silently disappearing. Option (c) was chosen over (b) because it keeps the rulesync config free of phantom servers while preserving the key, and it matches what Kilo's generate already does for unmanaged legacy keys.a.bwith legacytools: { a_b_: false, a_b_read: true }imported a phantom orphanawithb_andb_read(the latter was also attributed toa.b, so it was imported twice). Kilo's generate already keeps the unmanaged bare key in the legacy map.isBareOpencodeMcpServerPrefix({ key, serverNames })inopencode-family-mcp-tool-keys.ts, sharing one prefix builder withfindOpencodeMcpToolKeyOwnerandopencodeMcpToolPermissionKey.convertFromOpencodeFormatcomment no longer calls the second pass redundant (that word was already gone after fix(mcp): ignore bare sanitized OpenCode server prefixes #3727); it now explains that only the bare raw prefix (a.b_) still relies on the raw<server>_check, so that pass must stay. Thea_b/a_b_case was already in the fix(mcp): ignore bare sanitized OpenCode server prefixes #3727 matrix; a dedicateda.b/a.b_test now pins the raw-check-only case.it.eachmatrix carries the tool key in a case table (no nested ternary) and now also pinstoolsaftertoRulesyncMcp()→fromRulesyncMcp().Changes
src/features/shared/opencode-family-mcp-tool-keys.ts: newisBareOpencodeMcpServerPrefix, shared internalopencodeMcpServerKeyPrefix.src/features/mcp/opencode-mcp.ts: use the helper on import; preserve bare keys from the existing file on generate.src/features/mcp/kilo-mcp.ts: pre-filter owned and bare keys beforeorphanMcpToolFiltersToRulesync.docs/reference/file-formats.md,src/generated/docs-content.ts: note scope and bare-prefix behaviour.Tests
opencode-mcp.test.ts: matrix (OpenCode / V1 / MiMo × global × envelope ×a.b/a_b) now checks import and the regeneratedtools. The new generate assertions fail onmain(20 cases). Added a raw bare prefix (a.b_) case and a case where a generated filter wins over an existing bare key.kilo-mcp.test.ts:a.b/a_bimport without phantom orphans plus regenerate. Fails onmainwith phantoma/b_.opencode-family-mcp-tool-keys.test.ts: unit tests for the helper.pnpm cicheckpasses.Closes #3725
Closes #3728
🤖 Generated with Claude Code
https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth