Skip to content

fix(mcp): keep bare OpenCode server-prefix tool keys across import and generate - #3740

Merged
dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3728-opencode-mcp-bare-prefix
Nov 3, 2026
Merged

dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3728-opencode-mcp-bare-prefix

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Follow-ups to #3727 for OpenCode-family MCP tools keys that are exactly a listed server's sanitized <server>_ prefix (e.g. a_b_ for server a.b / a_b).

Changes

  • src/features/shared/opencode-family-mcp-tool-keys.ts: new isBareOpencodeMcpServerPrefix, shared internal opencodeMcpServerKeyPrefix.
  • 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 before orphanMcpToolFiltersToRulesync.
  • 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 regenerated tools. The new generate assertions fail on main (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_b import without phantom orphans plus regenerate. Fails on main with phantom a / b_.
  • opencode-family-mcp-tool-keys.test.ts: unit tests for the helper.
  • pnpm cicheck passes.

Closes #3725
Closes #3728

🤖 Generated with Claude Code

https://claude.ai/code/session_0179ZomNiDQHCzgoxeRVmfth

dyoshikawa and others added 4 commits November 3, 2026 16:30
…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
@dyoshikawa
dyoshikawa merged commit f2e3af7 into main Nov 3, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3728-opencode-mcp-bare-prefix branch November 3, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant