After integrating a local MCP server that provides code-analysis tools (analyze_dependencies, find_dead_code, calculate _complexity), you confirm that the server is healthy and that the tools appear in the tools/list response. However, the agent consistently uses Grep to search for import statements instead of calling analyze_dependencies—even when users explicitly ask about “code dependencies.”
Reviewing the tool definitions shows:
MCP: analyze_ dependencies – “Analyzes dependency graph”
Built-in: Grep – “Search file contents for a pattern using regular expressions. Returns matching lines with line numbers and surrounding context.”
What is the most effective way to improve the agent’s selection of MCP tools?
A Add routing instructions to the system prompt specifying that dependency-related questions should use MCP tools rather than Grep. B Remove Grep from available tools when the MCP server is connected to eliminate functional overlap. C Split analyze_dependencies into granular tools ( list_imports, resolve_transitive_deps, detect_circular_deps) so each has a focused purpose less likely to overlap with Grep. D Expand MCP tool descriptions to detail capabilities and outputs – e.g., “Builds dependency graph showing direct imports, transitive dependencies, and cycles.” Show Answer Answer Explanation Tool descriptions guide the model in deciding when and how to call a tool. Describing that analyze_dependencies builds a dependency graph and returns direct imports, transitive dependencies, and cycles clearly differentiates it from a text-search tool and enables appropriate selection for dependency-analysis requests.
Learn more
Community Discussion