opencode icon indicating copy to clipboard operation
opencode copied to clipboard

MCP Servers are not available if config is per project

Open xTamasu opened this issue 2 months ago • 5 comments

Description

MCP Servers are not available/detected if you define a config.json at your project-level. They work fine if you move the same config file to ~/.config/opencode/opencode.json.

OpenCode version

1.0.39

Steps to reproduce

  1. Create config at ~/.config/opencode/opencode.json

Insert:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "mcp_everything": {
      "type": "local",
      "command": ["npx", "-y", "@modelcontextprotocol/server-everything"],
    },
  },
}
  1. Run ``opencode run "use the mcp_everything tool to add the number 3 and 4. You're not allowed to calculate by yourself." Alternatively open opencode and run /status.
  2. Check if mcp usage is shown.
  3. Move ~/.config/opencode/opencode.json to your project root folder (.opencode/opencode.json)
  4. Run ``opencode run "use the mcp_everything tool to add the number 3 and 4. You're not allowed to calculate by yourself." Alternatively open opencode and run /status.
  5. Check if mcp usage is shown.

Screenshot and/or share link

No response

Operating System

macOS 15.6.1

Terminal

vs-code, zsh

xTamasu avatar Nov 07 '25 21:11 xTamasu

@xTamasu this is something we will fix, but we don't read in .opencode/opencode.json we only read it at the root of the project or globally, but this is a common confusion so we will fix that

rekram1-node avatar Nov 07 '25 22:11 rekram1-node

@rekram1-node What exactly means "at the root of the project"? How should it be placed? Its enough for me if I can at least somehow work non-global.

xTamasu avatar Nov 07 '25 23:11 xTamasu

@xTamasu any opencode.json or opencode.jsonc in your current working directory or in a parent directory should be picked up.

Now if this is a "project" aka it is a cloned git repo for example, then the root of your project is where the README.md and .gitignore files typically are.

I will also note that in the next release we will read from .opencode/ directories too tho

fix

rekram1-node avatar Nov 07 '25 23:11 rekram1-node

Image Image

got same ussue. while trying to use opencode mcp add opencode says that mcp was added successful, but nothing changed in the config file

{
  "$schema": "https://opencode.ai/config.json",

  // Теперь в global лежит только core (остальное уехало в skills).
  "instructions": ["./instructions/global/*.md"],

  "small_model": "openrouter/mimo-flash",

  "formatter": {
    "ruff": {
      "command": ["ruff", "format", "$FILE"],
      "extensions": [".py", ".pyi"],
      "environment": {
        "RUFF_NO_CACHE": "true",
        "RUFF_FORMAT_QUOTE_STYLE": "double",
        "RUFF_FORMAT_INDENT_STYLE": "space",
        "RUFF_FORMAT_SKIP_MAGIC_TRAILING_COMMA": "false",
        "RUFF_FORMAT_LINE_ENDING": "lf"
      }
    },

    // 3.4 — добавляем форматтер для фронта (как минимум JS/TS/CSS/HTML/JSON/MD).
    // Команду можно заменить на локально установленный prettier (например, ["pnpm","prettier",...])
    "prettier": {
      "command": ["npx", "prettier", "--write", "$FILE"],
      "extensions": [
        ".js",
        ".jsx",
        ".ts",
        ".tsx",
        ".css",
        ".scss",
        ".html",
        ".json",
        ".md",
        ".yaml",
        ".yml"
      ]
    }
  },

  "provider": {
    "openrouter": {
      "models": {
        "mimo-flash": {
          "id": "xiaomi/mimo-v2-flash:free",
          "name": "Xiaomi MiMo V2 Flash"
        },
        "gemini-flash": {
          "id": "google/gemini-2.0-flash-exp:free",
          "name": "Google Gemini 2.0 Flash Experimental"
        },
        "devstral": {
          "id": "mistralai/devstral-2512:free",
          "name": "Mistral Devstral 2"
        },
        "deepseek-r1t2": {
          "id": "tngtech/deepseek-r1t2-chimera:free",
          "name": "DeepSeek R1T2 Chimera"
        },
        "r1t-chimera": {
          "id": "tngtech/tng-r1t-chimera:free",
          "name": "R1T Chimera"
        }
      }
    }
  },

  "agent": {
    "build": {
      "mode": "primary",
      "model": "openrouter/mimo-flash",
      "description": "Primary Orchestrator / Integrator.\n\nWhat it does:\n- Owns end-to-end delivery: analyze → plan/delegate → implement → verify → document.\n- Loads the correct stack skill(s) (stack-django/stack-python/stack-frontend) before changing code.\n- Delegates specialized work to subagents (plan/docker/cicd/security/qa-tests/reviewer/docs/version-scout).\n- Uses MCP memory to persist project invariants (commands, ports, conventions, architectural decisions) across sessions.\n\nWhen to use:\n- Default agent for any coding task touching multiple files or requiring coordination.\n\nOutputs:\n- Concrete code/config changes + short verification steps + what to run locally/CI.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/build.md}",
      "tools": {
        "read": true,
        "write": true,
        "edit": true,
        "bash": true,
        "skill": true,
        "mcp": true
      }
    },

    "plan": {
      "mode": "primary",
      "model": "openrouter/mimo-flash",
      "description": "Architecture & Execution Planner.\n\nWhat it does:\n- Produces dependency-aware plans, risk analysis, and handoff instructions.\n- Loads relevant stack skill(s) before planning so the plan matches the project constraints.\n- Uses MCP memory to reuse prior architectural decisions and to persist new decisions.\n\nWhen to use:\n- Complex features, refactors, multi-service changes, unclear boundaries.\n\nOutputs:\n- Structured Markdown plan with phases, DoD, dependency graph, and risks.",
      "temperature": 0.2,
      "prompt": "{file:./instructions/inject/plan.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "qa-tests": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "QA Strategy & Test Design (pre-implementation).\n\nWhat it does:\n- Builds regression-proof test matrix (happy path, edge cases, failures, observability).\n- Enforces 'test first for bugfix': test must fail before fix and pass after.\n- Uses memory to persist agreed test commands and key scenarios.\n\nWhen to use:\n- Any non-trivial logic change; before implementation to define DoD for tests.\n\nOutputs:\n- Markdown test matrix + execution plan (without TODO/placeholders in executable snippets).",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/qa-tests.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "docker": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Containerization & Runtime Engineer.\n\nWhat it does:\n- Authors/reviews Dockerfile/docker-compose for correctness, security, caching, non-root, signals.\n- Follows your policy: prefer python:slim / python:alpine (no digest pinning).\n- Uses memory to persist build/run commands, ports, and container conventions.\n\nWhen to use:\n- Any Dockerfile/compose changes or runtime env questions.\n\nOutputs:\n- Full updated Dockerfile/compose + rationale + how to run/verify.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/docker.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "cicd": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "CI/CD Pipeline Engineer.\n\nWhat it does:\n- Designs fast, deterministic, secure pipelines (GitHub Actions by default).\n- Minimizes privileges, maximizes caching.\n- Uses memory to persist canonical CI commands and pipeline conventions.\n\nWhen to use:\n- Any workflow/pipeline changes.\n\nOutputs:\n- Ready-to-apply YAML workflows (no TODO placeholders; unknowns marked as UNKNOWN with a discovery plan).",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/cicd.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "reviewer": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Adversarial Code Reviewer (read-only).\n\nWhat it does:\n- Reviews diffs for correctness, performance, readability.\n- Also checks: migrations/DB safety, backward compatibility, secrets/logging/PII.\n- Uses memory to keep project-specific review checklist (if stable).\n\nWhen to use:\n- Always after implementation before shipping.\n\nOutputs:\n- Actionable findings with file:line, issue, fix, why.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/reviewer.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "security": {
      "mode": "subagent",
      "model": "openrouter/deepseek-r1t2",
      "description": "Security / Threat Modeling (white hat).\n\nWhat it does:\n- Threat models and audits for common vuln classes (SQLi/XSS/SSRF/IDOR/supply-chain).\n- Produces exploit scenario + exact remediation.\n- Uses memory to persist known attack surfaces and security decisions.\n\nWhen to use:\n- Auth, secrets, input handling, network boundaries, permission systems.\n\nOutputs:\n- Findings categorized CRITICAL/HIGH/MEDIUM + verification checklist.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/security.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "ideator": {
      "mode": "subagent",
      "model": "openrouter/r1t-chimera",
      "description": "Product / Solution Ideation (Tree of Thoughts).\n\nWhat it does:\n- Generates MVP/Strategic/Moonshot concept branches.\n- Helps when requirements unclear or you want options.\n- Can store stable product constraints in memory if useful.\n\nWhen to use:\n- Early discovery, brainstorming, when user wants multiple approaches.\n\nOutputs:\n- 3 concepts with user story, feasibility, wow-factor.",
      "temperature": 0.8,
      "prompt": "{file:./instructions/inject/ideator.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "docs": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Documentation / Developer Advocate.\n\nWhat it does:\n- Updates README and API docs so docs stay source-of-truth.\n- Ensures code blocks are copy/paste runnable.\n- Uses memory to persist canonical 'how to run/test' snippets.\n\nWhen to use:\n- Always when APIs change, new commands appear, or setup changes.\n\nOutputs:\n- List of files to update + full Markdown content.",
      "temperature": 0.2,
      "prompt": "{file:./instructions/inject/docs.md}",
      "tools": {
        "read": true,
        "write": true,
        "edit": true,
        "skill": true,
        "mcp": true
      }
    },

    "version-scout": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Dependency / Version Researcher (latest stable).\n\nWhat it does:\n- Uses webfetch to find latest stable releases for libraries/tools/images.\n- Never guesses versions. If unknown → UNKNOWN.\n- Also checks if project is on an older version and calls it out.\n- Uses memory to store 'last verified version + date' (but re-verifies if 'latest' is requested).\n\nWhen to use:\n- Poetry deps, tool upgrades, when you suspect repo is behind.\n\nOutputs:\n- Markdown table: component, latest stable version, release date, source link, notes.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/version-scout.md}",
      "tools": {
        "read": true,
        "webfetch": true,
        "skill": true,
        "mcp": true
      }
    }
  },

  "permission": {
    "read": "allow",
    "edit": "allow",
    "write": "allow",
    "webfetch": "allow",

    "skill": { "*": "allow" },

    // 3.3 — фиксируем явно, чтобы поведение было читаемо в конфиге.
    "doom_loop": "ask",
    "external_directory": "ask",

    // 3.3 — делаем ask на явно опасные команды, остальное оставляем allow.
    "bash": {
      "git commit*": "allow",
      "git push": "ask",

      "rm *": "ask",
      "sudo *": "ask",
      "git reset *": "ask",
      "git clean *": "ask",
      "docker system prune*": "ask",

      "*": "allow"
    },

    "mcp": {
      "context7": {
        "type": "local",
        "command": ["npx", "-y", "@upstash/context7-mcp@latest"],
        "enabled": true,
        "timeout": 60000
      },
      "sequential-thinking": {
        "type": "local",
        "command": ["npx", "-y", "@modelcontextprotocol/server-sequential-thinking"],
        "enabled": true,
        "timeout": 60000
      },
      "memory": {
        "type": "local",
        "command": ["npx", "-y", "@modelcontextprotocol/server-memory"],
        "enabled": true,
        "timeout": 60000
      }
    }
  }
}

An0nX avatar Dec 30 '25 13:12 An0nX

Image Image got same ussue. while trying to use opencode mcp add opencode says that mcp was added successful, but nothing changed in the config file

{
  "$schema": "https://opencode.ai/config.json",

  // Теперь в global лежит только core (остальное уехало в skills).
  "instructions": ["./instructions/global/*.md"],

  "small_model": "openrouter/mimo-flash",

  "formatter": {
    "ruff": {
      "command": ["ruff", "format", "$FILE"],
      "extensions": [".py", ".pyi"],
      "environment": {
        "RUFF_NO_CACHE": "true",
        "RUFF_FORMAT_QUOTE_STYLE": "double",
        "RUFF_FORMAT_INDENT_STYLE": "space",
        "RUFF_FORMAT_SKIP_MAGIC_TRAILING_COMMA": "false",
        "RUFF_FORMAT_LINE_ENDING": "lf"
      }
    },

    // 3.4 — добавляем форматтер для фронта (как минимум JS/TS/CSS/HTML/JSON/MD).
    // Команду можно заменить на локально установленный prettier (например, ["pnpm","prettier",...])
    "prettier": {
      "command": ["npx", "prettier", "--write", "$FILE"],
      "extensions": [
        ".js",
        ".jsx",
        ".ts",
        ".tsx",
        ".css",
        ".scss",
        ".html",
        ".json",
        ".md",
        ".yaml",
        ".yml"
      ]
    }
  },

  "provider": {
    "openrouter": {
      "models": {
        "mimo-flash": {
          "id": "xiaomi/mimo-v2-flash:free",
          "name": "Xiaomi MiMo V2 Flash"
        },
        "gemini-flash": {
          "id": "google/gemini-2.0-flash-exp:free",
          "name": "Google Gemini 2.0 Flash Experimental"
        },
        "devstral": {
          "id": "mistralai/devstral-2512:free",
          "name": "Mistral Devstral 2"
        },
        "deepseek-r1t2": {
          "id": "tngtech/deepseek-r1t2-chimera:free",
          "name": "DeepSeek R1T2 Chimera"
        },
        "r1t-chimera": {
          "id": "tngtech/tng-r1t-chimera:free",
          "name": "R1T Chimera"
        }
      }
    }
  },

  "agent": {
    "build": {
      "mode": "primary",
      "model": "openrouter/mimo-flash",
      "description": "Primary Orchestrator / Integrator.\n\nWhat it does:\n- Owns end-to-end delivery: analyze → plan/delegate → implement → verify → document.\n- Loads the correct stack skill(s) (stack-django/stack-python/stack-frontend) before changing code.\n- Delegates specialized work to subagents (plan/docker/cicd/security/qa-tests/reviewer/docs/version-scout).\n- Uses MCP memory to persist project invariants (commands, ports, conventions, architectural decisions) across sessions.\n\nWhen to use:\n- Default agent for any coding task touching multiple files or requiring coordination.\n\nOutputs:\n- Concrete code/config changes + short verification steps + what to run locally/CI.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/build.md}",
      "tools": {
        "read": true,
        "write": true,
        "edit": true,
        "bash": true,
        "skill": true,
        "mcp": true
      }
    },

    "plan": {
      "mode": "primary",
      "model": "openrouter/mimo-flash",
      "description": "Architecture & Execution Planner.\n\nWhat it does:\n- Produces dependency-aware plans, risk analysis, and handoff instructions.\n- Loads relevant stack skill(s) before planning so the plan matches the project constraints.\n- Uses MCP memory to reuse prior architectural decisions and to persist new decisions.\n\nWhen to use:\n- Complex features, refactors, multi-service changes, unclear boundaries.\n\nOutputs:\n- Structured Markdown plan with phases, DoD, dependency graph, and risks.",
      "temperature": 0.2,
      "prompt": "{file:./instructions/inject/plan.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "qa-tests": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "QA Strategy & Test Design (pre-implementation).\n\nWhat it does:\n- Builds regression-proof test matrix (happy path, edge cases, failures, observability).\n- Enforces 'test first for bugfix': test must fail before fix and pass after.\n- Uses memory to persist agreed test commands and key scenarios.\n\nWhen to use:\n- Any non-trivial logic change; before implementation to define DoD for tests.\n\nOutputs:\n- Markdown test matrix + execution plan (without TODO/placeholders in executable snippets).",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/qa-tests.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "docker": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Containerization & Runtime Engineer.\n\nWhat it does:\n- Authors/reviews Dockerfile/docker-compose for correctness, security, caching, non-root, signals.\n- Follows your policy: prefer python:slim / python:alpine (no digest pinning).\n- Uses memory to persist build/run commands, ports, and container conventions.\n\nWhen to use:\n- Any Dockerfile/compose changes or runtime env questions.\n\nOutputs:\n- Full updated Dockerfile/compose + rationale + how to run/verify.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/docker.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "cicd": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "CI/CD Pipeline Engineer.\n\nWhat it does:\n- Designs fast, deterministic, secure pipelines (GitHub Actions by default).\n- Minimizes privileges, maximizes caching.\n- Uses memory to persist canonical CI commands and pipeline conventions.\n\nWhen to use:\n- Any workflow/pipeline changes.\n\nOutputs:\n- Ready-to-apply YAML workflows (no TODO placeholders; unknowns marked as UNKNOWN with a discovery plan).",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/cicd.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "reviewer": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Adversarial Code Reviewer (read-only).\n\nWhat it does:\n- Reviews diffs for correctness, performance, readability.\n- Also checks: migrations/DB safety, backward compatibility, secrets/logging/PII.\n- Uses memory to keep project-specific review checklist (if stable).\n\nWhen to use:\n- Always after implementation before shipping.\n\nOutputs:\n- Actionable findings with file:line, issue, fix, why.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/reviewer.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "security": {
      "mode": "subagent",
      "model": "openrouter/deepseek-r1t2",
      "description": "Security / Threat Modeling (white hat).\n\nWhat it does:\n- Threat models and audits for common vuln classes (SQLi/XSS/SSRF/IDOR/supply-chain).\n- Produces exploit scenario + exact remediation.\n- Uses memory to persist known attack surfaces and security decisions.\n\nWhen to use:\n- Auth, secrets, input handling, network boundaries, permission systems.\n\nOutputs:\n- Findings categorized CRITICAL/HIGH/MEDIUM + verification checklist.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/security.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "ideator": {
      "mode": "subagent",
      "model": "openrouter/r1t-chimera",
      "description": "Product / Solution Ideation (Tree of Thoughts).\n\nWhat it does:\n- Generates MVP/Strategic/Moonshot concept branches.\n- Helps when requirements unclear or you want options.\n- Can store stable product constraints in memory if useful.\n\nWhen to use:\n- Early discovery, brainstorming, when user wants multiple approaches.\n\nOutputs:\n- 3 concepts with user story, feasibility, wow-factor.",
      "temperature": 0.8,
      "prompt": "{file:./instructions/inject/ideator.md}",
      "tools": {
        "read": true,
        "skill": true,
        "mcp": true
      }
    },

    "docs": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Documentation / Developer Advocate.\n\nWhat it does:\n- Updates README and API docs so docs stay source-of-truth.\n- Ensures code blocks are copy/paste runnable.\n- Uses memory to persist canonical 'how to run/test' snippets.\n\nWhen to use:\n- Always when APIs change, new commands appear, or setup changes.\n\nOutputs:\n- List of files to update + full Markdown content.",
      "temperature": 0.2,
      "prompt": "{file:./instructions/inject/docs.md}",
      "tools": {
        "read": true,
        "write": true,
        "edit": true,
        "skill": true,
        "mcp": true
      }
    },

    "version-scout": {
      "mode": "subagent",
      "model": "openrouter/mimo-flash",
      "description": "Dependency / Version Researcher (latest stable).\n\nWhat it does:\n- Uses webfetch to find latest stable releases for libraries/tools/images.\n- Never guesses versions. If unknown → UNKNOWN.\n- Also checks if project is on an older version and calls it out.\n- Uses memory to store 'last verified version + date' (but re-verifies if 'latest' is requested).\n\nWhen to use:\n- Poetry deps, tool upgrades, when you suspect repo is behind.\n\nOutputs:\n- Markdown table: component, latest stable version, release date, source link, notes.",
      "temperature": 0.1,
      "prompt": "{file:./instructions/inject/version-scout.md}",
      "tools": {
        "read": true,
        "webfetch": true,
        "skill": true,
        "mcp": true
      }
    }
  },

  "permission": {
    "read": "allow",
    "edit": "allow",
    "write": "allow",
    "webfetch": "allow",

    "skill": { "*": "allow" },

    // 3.3 — фиксируем явно, чтобы поведение было читаемо в конфиге.
    "doom_loop": "ask",
    "external_directory": "ask",

    // 3.3 — делаем ask на явно опасные команды, остальное оставляем allow (как у тебя было).
    "bash": {
      "git commit*": "allow",
      "git push": "ask",

      "rm *": "ask",
      "sudo *": "ask",
      "git reset *": "ask",
      "git clean *": "ask",
      "docker system prune*": "ask",

      "*": "allow"
    },

    "mcp": {
      "context7": {
        "type": "local",
        "command": ["npx", "-y", "@upstash/context7-mcp@latest"],
        "enabled": true,
        "timeout": 60000
      },
      "sequential-thinking": {
        "type": "local",
        "command": ["npx", "-y", "@modelcontextprotocol/server-sequential-thinking"],
        "enabled": true,
        "timeout": 60000
      },
      "memory": {
        "type": "local",
        "command": ["npx", "-y", "@modelcontextprotocol/server-memory"],
        "enabled": true,
        "timeout": 60000
      }
    }
  }
}

+1

yaleh avatar Jan 04 '26 08:01 yaleh