Summary
Add a declarative optional MCP framework to ai-engkit so non-core MCP tools can be enabled safely without relying on ad-hoc in-container installs or manual opencode mcp add drift.
Problem / use case
Today ai-engkit's built-in MCP stack is durable because:
- binaries are installed at image build time,
entrypoint.d/02-init-config.sh regenerates ~/.config/opencode/opencode.json on startup,
- selected tool state is stored on volumes.
That model does not yet exist for optional MCPs. In Docker, a manually installed MCP can disappear after recreate/rebuild, while a manually added OpenCode MCP entry can be overwritten when opencode.json is regenerated.
zhtw-mcp is a good motivating case:
- useful only for some users,
- single-binary Rust tool,
- not auto-registered to OpenCode by upstream install scripts.
Proposed solution
Implement an optional MCP registry consumed by the entrypoint when generating OpenCode config.
High-level design:
- add
/etc/opencode/optional-mcp.json for image defaults
- add
~/.config/opencode/optional-mcp.json for persistent user overrides
- merge both registries during startup
- append only enabled MCP entries whose commands resolve successfully
- create any declared required paths before registration
- keep
opencode.json entrypoint-owned instead of user-mutated
Initial design draft:
docs/knowledge/architecture/optional-mcp-architecture.md
Alternatives considered
-
Manual opencode mcp add inside the container
- fragile because
opencode.json is regenerated on startup
- easy to lose during rebuild/recreate
-
Volume-only optional MCP installs
- workable, but requires extra persistent binary path management and more recovery logic
-
Bake every candidate MCP into the base image and enable all by default
- simplest operationally, but wrong for niche tools and image bloat
Scope and impact
Other:
- OpenCode config generation
- optional persistence paths for MCP-local caches/config
Additional context
Recommended phased rollout:
- Add the generic optional MCP framework first.
- Add tests for disabled, enabled, and missing-binary cases.
- Integrate
zhtw-mcp as the first optional MCP.
Recommended initial zhtw-mcp treatment:
- install strategy: image-baked binary
- default: disabled
- enabled via env and/or persistent user override file
Language
Traditional Chinese acceptable.
Checklist
Summary
Add a declarative optional MCP framework to ai-engkit so non-core MCP tools can be enabled safely without relying on ad-hoc in-container installs or manual
opencode mcp adddrift.Problem / use case
Today ai-engkit's built-in MCP stack is durable because:
entrypoint.d/02-init-config.shregenerates~/.config/opencode/opencode.jsonon startup,That model does not yet exist for optional MCPs. In Docker, a manually installed MCP can disappear after recreate/rebuild, while a manually added OpenCode MCP entry can be overwritten when
opencode.jsonis regenerated.zhtw-mcpis a good motivating case:Proposed solution
Implement an optional MCP registry consumed by the entrypoint when generating OpenCode config.
High-level design:
/etc/opencode/optional-mcp.jsonfor image defaults~/.config/opencode/optional-mcp.jsonfor persistent user overridesopencode.jsonentrypoint-owned instead of user-mutatedInitial design draft:
docs/knowledge/architecture/optional-mcp-architecture.mdAlternatives considered
Manual
opencode mcp addinside the containeropencode.jsonis regenerated on startupVolume-only optional MCP installs
Bake every candidate MCP into the base image and enable all by default
Scope and impact
Other:
Additional context
Recommended phased rollout:
zhtw-mcpas the first optional MCP.Recommended initial
zhtw-mcptreatment:Language
Traditional Chinese acceptable.
Checklist