Summary
The current LSP-MCP server exposes 3 separate call hierarchy tools that could be consolidated into a single, more intuitive tool.
Current State
Three separate tools:
-
prepare_call_hierarchy
- Returns call hierarchy items at a position
- This is an intermediate LSP call - not useful standalone
- Requires follow-up with
incoming_calls or outgoing_calls
-
incoming_calls
- Finds functions that call the function at position
- Requires internal handling of
prepare_call_hierarchy first
-
outgoing_calls
- Finds functions called by the function at position
- Also requires
prepare_call_hierarchy internally
Problems:
prepare_call_hierarchy is useless alone - An LLM has to know to call incoming_calls or outgoing_calls afterward
- Three tools for one concept - Adds cognitive overhead and tool list bloat
- Inconsistent with other tools - No other LSP feature is split across multiple tools like this
Proposed Change
Consolidate into a single call_graph tool:
#[tool(description = "Find incoming/outgoing function calls at a position")]
async fn call_graph(
&self,
path: String,
line: u32,
character: u32,
direction: String, // "incoming" | "outgoing" | "both"
include_raw_response: Option<bool>,
) -> ToolOutput
Usage examples:
// Find what calls this function
{"path": "src/mcp.rs", "line": 32, "character": 13, "direction": "incoming"}
// Find what this function calls
{"path": "src/mcp.rs", "line": 32, "character": 13, "direction": "outgoing"}
// Get full call graph (both directions)
{"path": "src/mcp.rs", "line": 32, "character": 13, "direction": "both"}
Response format:
{
"function": {
"name": "definitions_in_file",
"location": {"path": "src/mcp.rs", "line": 32, "character": 13}
},
"incoming_calls": [...], // present if direction is "incoming" or "both"
"outgoing_calls": [...] // present if direction is "outgoing" or "both"
}
Implementation Notes
- Internally,
call_graph would still call prepare_call_hierarchy first
- The consolidation is purely at the MCP tool interface level
- Backwards compatibility: Keep old tools available but remove from presets
Impact
- Reduces tool count by 2 (3 tools → 1 tool)
- Simpler mental model for LLM agents
- More intuitive API - one tool for call relationships
- Optional "both" direction enables richer analysis in single call
Related
Summary
The current LSP-MCP server exposes 3 separate call hierarchy tools that could be consolidated into a single, more intuitive tool.
Current State
Three separate tools:
prepare_call_hierarchyincoming_callsoroutgoing_callsincoming_callsprepare_call_hierarchyfirstoutgoing_callsprepare_call_hierarchyinternallyProblems:
prepare_call_hierarchyis useless alone - An LLM has to know to callincoming_callsoroutgoing_callsafterwardProposed Change
Consolidate into a single
call_graphtool:Usage examples:
Response format:
{ "function": { "name": "definitions_in_file", "location": {"path": "src/mcp.rs", "line": 32, "character": 13} }, "incoming_calls": [...], // present if direction is "incoming" or "both" "outgoing_calls": [...] // present if direction is "outgoing" or "both" }Implementation Notes
call_graphwould still callprepare_call_hierarchyfirstImpact
Related
.ai_agents/tool_review.md