MoonshotAI / MoonshotAI/kimi-cli
[Feature Request] MCP/Skill Tool Usage Priority Configuration - Need a standardized way to define tool precedence
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
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
- Function-based grouping - Group tools by capability (search, read, write, navigate) rather than by source
- Conditional logic - Allow rules like "use IDE tools when available, fallback to filesystem"
- Human-readable - Both humans and AI should understand the priorities
- 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:
- Uses
Grepwhenide_search_textwould be more accurate - Uses
ReadFilewhenget_file_text_by_path(from IDE) would maintain proper indexing - 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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the current MCP configuration handling and any existing AGENTS.md instruction parsing in Kimi Code CLI. Compare the proposed mcp.json, .ai/tool-priority.yaml, and AGENTS.md approaches, then clarify the preferred design, supported rule semantics, and acceptance criteria before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100