diff options
| author | Matt Silverlock <[email protected]> | 2026-01-07 11:07:21 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-07 12:07:21 -0500 |
| commit | 4ba0b22b04fb593fde23ba72c75735af3cb29af6 (patch) | |
| tree | fefdb28b981442f9d9e8417b4810d7fed7d93ae2 /packages/web/src/content/docs | |
| parent | 662d2b205a165a26520cc8193de98b8edfd07a3d (diff) | |
| download | opencode-4ba0b22b04fb593fde23ba72c75735af3cb29af6.tar.gz opencode-4ba0b22b04fb593fde23ba72c75735af3cb29af6.zip | |
fix: config precedence now correctly allows local config to override remote (#7141)
Diffstat (limited to 'packages/web/src/content/docs')
| -rw-r--r-- | packages/web/src/content/docs/config.mdx | 65 | ||||
| -rw-r--r-- | packages/web/src/content/docs/mcp-servers.mdx | 23 |
2 files changed, 82 insertions, 6 deletions
diff --git a/packages/web/src/content/docs/config.mdx b/packages/web/src/content/docs/config.mdx index d9076e13a..a5931b6fc 100644 --- a/packages/web/src/content/docs/config.mdx +++ b/packages/web/src/content/docs/config.mdx @@ -32,21 +32,74 @@ different order of precedence. Configuration files are **merged together**, not replaced. ::: -Configuration files are merged together, not replaced. Settings from the following config locations are combined. Where later configs override earlier ones only for conflicting keys. Non-conflicting settings from all configs are preserved. +Configuration files are merged together, not replaced. Settings from the following config locations are combined. Later configs override earlier ones only for conflicting keys. Non-conflicting settings from all configs are preserved. For example, if your global config sets `theme: "opencode"` and `autoupdate: true`, and your project config sets `model: "anthropic/claude-sonnet-4-5"`, the final configuration will include all three settings. --- +### Precedence order + +Config sources are loaded in this order (later sources override earlier ones): + +1. **Remote config** (from `.well-known/opencode`) - organizational defaults +2. **Global config** (`~/.config/opencode/opencode.json`) - user preferences +3. **Custom config** (`OPENCODE_CONFIG` env var) - custom overrides +4. **Project config** (`opencode.json` in project) - project-specific settings +5. **`.opencode` directories** - agents, commands, plugins +6. **Inline config** (`OPENCODE_CONFIG_CONTENT` env var) - runtime overrides + +This means project configs can override global defaults, and global configs can override remote organizational defaults. + +--- + +### Remote + +Organizations can provide default configuration via the `.well-known/opencode` endpoint. This is fetched automatically when you authenticate with a provider that supports it. + +Remote config is loaded first, serving as the base layer. All other config sources (global, project) can override these defaults. + +For example, if your organization provides MCP servers that are disabled by default: + +```json title="Remote config from .well-known/opencode" +{ + "mcp": { + "jira": { + "type": "remote", + "url": "https://jira.example.com/mcp", + "enabled": false + } + } +} +``` + +You can enable specific servers in your local config: + +```json title="opencode.json" +{ + "mcp": { + "jira": { + "type": "remote", + "url": "https://jira.example.com/mcp", + "enabled": true + } + } +} +``` + +--- + ### Global -Place your global OpenCode config in `~/.config/opencode/opencode.json`. You'll want to use the global config for things like themes, providers, or keybinds. +Place your global OpenCode config in `~/.config/opencode/opencode.json`. Use global config for user-wide preferences like themes, providers, or keybinds. + +Global config overrides remote organizational defaults. --- ### Per project -You can also add a `opencode.json` in your project. Settings from this config are merged with and can override the global config. This is useful for configuring providers or modes specific to your project. +Add `opencode.json` in your project root. Project config has the highest precedence among standard config files - it overrides both global and remote configs. :::tip Place project specific config in the root of your project. @@ -60,20 +113,20 @@ This is also safe to be checked into Git and uses the same schema as the global ### Custom path -You can also specify a custom config file path using the `OPENCODE_CONFIG` environment variable. +Specify a custom config file path using the `OPENCODE_CONFIG` environment variable. ```bash export OPENCODE_CONFIG=/path/to/my/custom-config.json opencode run "Hello world" ``` -Settings from this config are merged with and **can override** the global and project configs. +Custom config is loaded between global and project configs in the precedence order. --- ### Custom directory -You can specify a custom config directory using the `OPENCODE_CONFIG_DIR` +Specify a custom config directory using the `OPENCODE_CONFIG_DIR` environment variable. This directory will be searched for agents, commands, modes, and plugins just like the standard `.opencode` directory, and should follow the same structure. diff --git a/packages/web/src/content/docs/mcp-servers.mdx b/packages/web/src/content/docs/mcp-servers.mdx index 9d8b3e052..cb9e6a79b 100644 --- a/packages/web/src/content/docs/mcp-servers.mdx +++ b/packages/web/src/content/docs/mcp-servers.mdx @@ -44,6 +44,29 @@ You can also disable a server by setting `enabled` to `false`. This is useful if --- +### Overriding remote defaults + +Organizations can provide default MCP servers via their `.well-known/opencode` endpoint. These servers may be disabled by default, allowing users to opt-in to the ones they need. + +To enable a specific server from your organization's remote config, add it to your local config with `enabled: true`: + +```json title="opencode.json" +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "jira": { + "type": "remote", + "url": "https://jira.example.com/mcp", + "enabled": true + } + } +} +``` + +Your local config values override the remote defaults. See [config precedence](/docs/config#precedence-order) for more details. + +--- + ## Local Add local MCP servers using `type` to `"local"` within the MCP object. |
