[PR #1170] [CLOSED] feat(config): add support for loading MCP configuration from mcp.json #9835

Closed
opened 2026-02-16 18:14:15 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1170
Author: @delafthi
Created: 7/20/2025
Status: Closed

Base: devHead: push-spkoxwxpwuun


📝 Commits (1)

  • 94c204c feat(config): add support for loading MCP configuration from mcp.json

📊 Changes

2 files changed (+1025 additions, -504 deletions)

View changed files

📝 packages/opencode/src/config/config.ts (+754 -504)
packages/opencode/src/config/mcp.ts (+271 -0)

📄 Description

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 McpConfig namespace 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.ts and config.ts and could be refactored to reduce duplication.

Additional Notes

This PR was primarily generated by Claude Sonnet 4.

What do you guys think?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1170 **Author:** [@delafthi](https://github.com/delafthi) **Created:** 7/20/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `push-spkoxwxpwuun` --- ### 📝 Commits (1) - [`94c204c`](https://github.com/anomalyco/opencode/commit/94c204c9358664f68a8c09329d785f960c22b45b) feat(config): add support for loading MCP configuration from `mcp.json` ### 📊 Changes **2 files changed** (+1025 additions, -504 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/config/config.ts` (+754 -504) ➕ `packages/opencode/src/config/mcp.ts` (+271 -0) </details> ### 📄 Description 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 `McpConfig` namespace 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.ts` and `config.ts` and could be refactored to reduce duplication. ### Additional Notes This PR was primarily generated by Claude Sonnet 4. What do you guys think? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:15 -05:00
yindo closed this issue 2026-02-16 18:14:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9835