opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Feature request: Allow project-level tool description augmentation for MCP/built-in tools

Open skywalker-35 opened this issue 5 months ago • 1 comments

Problem

When a user registers an MCP tool (e.g. CodeGraph) and writes instructions in AGENTS.md to prefer it over built-in tools like grep, the model still chooses the built-in tool for structured code queries.

The root cause: the model selects tools at inference time based on semantic matching between the current query and the tool's hardcoded description. Built-in tools like grep have descriptions injected into every single inference call as part of the system prompt. AGENTS.md instructions, on the other hand, are loaded once at session start and pushed further out of the attention window as the conversation grows. The tool description always wins because it is far closer to the decision point.

This means:

  • MCP tools that are objectively better for certain query types are systematically underused
  • AGENTS.md instructions about tool preference have limited effect because they compete with hardcoded tool descriptions
  • Users invest effort setting up MCP tools and writing rules, only to find the model ignores both

Proposed Solution

Allow users to augment or override tool descriptions at the project level, either through opencode.json(c) or through directives embedded in AGENTS.md.

Option A: Config-level description augmentation

{
  "toolDescriptions": {
    "grep": {
      "append": "For structured code queries (function definitions, class hierarchies, callers/callees, import graphs), prefer codegraph_search or codegraph_explore."
    }
  }
}

Option B: AGENTS.md-based directive that gets injected into tool descriptions

A special markdown section that opencode parses and appends to the corresponding tool description at session start, rather than placing it in the general instruction text:

## {tool:grep}
For structured code queries (function definitions, class hierarchies, caller/callee relationships, import graphs), prefer codegraph_search or codegraph_explore.

Why This Matters

Currently, a user can:

  1. Install CodeGraph MCP
  2. Set up .codegraph/ indexing
  3. Write detailed "CodeGraph first" rules in AGENTS.md
  4. ...and the model still calls grep for structural queries

Steps 1-3 represent significant effort with no reliable outcome. This feature would close the gap between "instructions about tools" and "the model's actual tool selection behavior" by placing the hint where the model makes the decision at the tool description level.

Prior Art

  • Cursor's Auto Rules feature allows conditionally attaching rules based on file context
  • Some users work around this by using custom system prompts or by aggressively restricting permissions via deny rules

Expected Impact

  • Low implementation complexity (description strings are trivial to append)
  • High impact on MCP tool adoption and user satisfaction
  • No breaking changes to existing configurations
  • Respects the existing permission/agent architecture

skywalker-35 avatar Jun 15 '26 02:06 skywalker-35

This issue doesn't fully meet our contributing guidelines.

What needs to be fixed:

  • Feature requests must have a title starting with [FEATURE]: (current title: "Feature request: Allow project-level tool description augmentation for MCP/built-in tools")
  • Feature requests must include the verification checkbox confirming the feature hasn't been suggested before (the standard feature request template checkbox is missing)

Please edit this issue to address the above within 2 hours, or it will be automatically closed.


This issue might be a duplicate of existing issues. Please check:

  • #11604: [FEATURE]: Allow custom tool description — requests the ability to customize/override hardcoded tool descriptions via config or plugin system, which overlaps significantly with this request

If you believe this was flagged incorrectly, please let a maintainer know.

github-actions[bot] avatar Jun 15 '26 02:06 github-actions[bot]

This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new issue that follows our issue templates.

github-actions[bot] avatar Jun 15 '26 05:06 github-actions[bot]