Skip to content

[Feature Request] MCP/Skill Tool Usage Priority Configuration - Need a standardized way to define tool precedence #1537

Description

@zhang-xzh

Problem Statement

In real-world agent usage, projects often integrate multiple MCP servers and Skills that provide overlapping functionality. Currently, there is no standardized mechanism to define which tool should be preferred when multiple tools can accomplish the same task.

Real-World Example

In our project, we have three tools that can search for files:

Tool Source Capability
ide_find_file intellij-index MCP IDE-indexed file search with semantic understanding
find_files_by_glob intellij-util MCP Glob pattern matching via IDE
Glob Built-in Basic filesystem glob

Current behavior: The LLM randomly selects among these tools without understanding which is most appropriate.

Expected behavior: A clear priority hierarchy:

intellij-index > intellij-util > built-in tools

Current Industry Landscape

After investigating major AI coding tools, none provide a standardized solution for this problem:

Tool Configuration Files Tool Priority Support
Claude Code CLAUDE.md, AGENTS.md, .mcp.json ❌ No priority mechanism
Cursor .cursor/rules/*.mdc, ~/.cursor/mcp.json ⚠️ Rules have priority metadata, but not for MCP tools
Roo Code .roo/rules/, .roorules ❌ No priority mechanism
Cline .clinerules/ ❌ No priority mechanism
LangChain Deep Agents .mcp.json (auto-discovery) ⚠️ Config-level priority only (user < project < explicit)

Proposed Solutions

Option 1: Extend mcp.json with Priority Metadata (Recommended)

Add a toolPriority section to the MCP configuration:

{
  "mcpServers": {
    "intellij-index": { "url": "http://localhost:29173/index-mcp/streamable-http" },
    "intellij-util": { "type": "stdio", "command": "..." }
  },
  "toolPriority": {
    "file_search": [
      { "server": "intellij-index", "tool": "ide_find_file" },
      { "server": "intellij-util", "tool": "find_files_by_glob" },
      { "builtin": "Glob" }
    ],
    "code_navigation": [
      { "server": "intellij-index", "tool": "ide_find_definition" },
      { "server": "intellij-index", "tool": "ide_find_references" }
    ]
  }
}

Option 2: Separate Configuration File (.ai/tool-priority.yaml)

Create a dedicated file for tool usage rules:

# .ai/tool-priority.yaml
version: 1

categories:
  file_search:
    description: "Search for files in the project"
    priority:
      - server: intellij-index
        tool: ide_find_file
        reason: "IDE-indexed, most accurate"
      - server: intellij-util
        tool: find_files_by_glob
        reason: "IDE-backed glob matching"
      - builtin: Glob
        reason: "Fallback for basic cases"

  code_search:
    description: "Search code content"
    priority:
      - server: intellij-index
        tool: ide_search_text
      - builtin: Grep
        condition: "when IDE tools unavailable"

rules:
  - when: "working_with_code"
    prefer: "intellij-index"
    reason: "IDE tools provide semantic understanding"
  
  - when: "pure_file_operations"
    prefer: "filesystem"
    reason: "Avoid IDE overhead for simple tasks"

Option 3: Extend AGENTS.md with Tool Priority Section

Leverage the existing AGENTS.md convention:

# Tool Usage Priority

## Hierarchy

1. **intellij-index** - Primary for all code-related operations
   - `ide_find_definition` - Go to symbol definition
   - `ide_find_references` - Find symbol usages
   - `ide_search_text` - Search in codebase

2. **intellij-util** - Secondary for file operations
   - `find_files_by_glob` - Pattern matching
   - `ide_move_file` - Refactoring operations

3. **filesystem** - Fallback for pure file I/O
   - `ReadFile`, `WriteFile` - When IDE tools unavailable

This content could be parsed and injected into the system prompt with structured formatting.

Key Requirements

  1. Function-based grouping - Group tools by capability (search, read, write, navigate) rather than by source
  2. Conditional logic - Allow rules like "use IDE tools when available, fallback to filesystem"
  3. Human-readable - Both humans and AI should understand the priorities
  4. Version control friendly - Text-based, diff-friendly format

Benefits

  • Consistency - Ensures optimal tool selection across different sessions
  • Token efficiency - Avoids redundant tool calls
  • Better results - Uses semantically appropriate tools for each task
  • Maintainability - Centralized configuration for tool preferences

Additional Context

This issue was discovered while building a Next.js project where we have both IDE MCP servers (for code intelligence) and standard filesystem tools. The LLM frequently:

  1. Uses Grep when ide_search_text would be more accurate
  2. Uses ReadFile when get_file_text_by_path (from IDE) would maintain proper indexing
  3. Doesn't understand when to prefer IDE-backed refactoring tools over basic file operations

A standardized priority configuration would solve this systematically rather than relying on prompt engineering in each session.


Would love to hear thoughts on which approach aligns best with Kimi Code CLI's design philosophy!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions