Skip to content

[BUG] MCP servers defined in ~/.claude are loaded even when OPENCODE_CONFIG_DIR is set #18691

Description

@MinhoJJang

Problem

When OPENCODE_CONFIG_DIR is set to a custom directory, opencode still unconditionally loads MCP servers from ~/.claude.

My setup:

export OPENCODE_CONFIG_DIR="$HOME/obsidian/Opencode"

opencode() {
  XDG_CONFIG_HOME="$HOME/obsidian/Opencode/config" \
  XDG_DATA_HOME="$HOME/obsidian/Opencode/data" \
  command opencode "$@"
}

mcp.json inside OPENCODE_CONFIG_DIR only has one server registered:

{
  "mcpServers": {
    "awslabs.aws-api-mcp-server": { ... }
  }
}

But when opencode starts, MCP servers from ~/.claude (e.g. claude-hud, Notion MCP) also get loaded and appear in the context. I want opencode to read config exclusively from OPENCODE_CONFIG_DIR and not touch ~/.claude at all.

Root Cause

From what I can tell, the ~/.claude scan for MCP server definitions is in a separate code path from system.ts / skill.ts, and is not gated by any environment variable. It seems opencode treats ~/.claude as a Claude Code compatibility layer unconditionally.

Related but doesn't cover this:

Expected Behavior

When OPENCODE_CONFIG_DIR is explicitly set, opencode should load MCP servers only from that directory and skip ~/.claude entirely (or at least provide an opt-out flag).

Environment

  • opencode v1.3.0
  • macOS
  • OPENCODE_CONFIG_DIR set to a vault directory shared across machines via git

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions