opencode
opencode copied to clipboard
feat(config): add support for loading MCP configuration from `mcp.json`
This PR adds support for loading MCP configuration from mcp.json files, enabling more flexible and backward-compatible configuration management.
Changes
- Load MCP configuration from both global (
~/.config/opencode/mcp.json) and local (.mcp.json) files. - Introduce a new
McpConfignamespace dedicated to managing MCP server configurations. - Support typed and legacy MCP server formats, validated via Zod schemas to ensure correctness.
- Implement variable and file expansion supporting
{VAR}and{VAR:-default}syntax for enhanced configuration flexibility. - Merge global and local MCP configs into the main config state, converting legacy formats to the current structure for backward compatibility.
- Note: The variable expansion logic currently exists in both
mcp.tsandconfig.tsand could be refactored to reduce duplication.
Additional Notes
This PR was primarily generated by Claude Sonnet 4.
What do you guys think?