Skip to content

Commit 5064382

Browse files
committed
Clarify and expand include_content documentation: emphasize two-step workflow for current repositories, strengthen critical rules, and enhance examples for proper usage.
1 parent f73f80b commit 5064382

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/tools/search.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,23 @@ async def codebase_search(
7070
7171
include_content: Whether to include full file content in results (default: false).
7272
73+
⚠️ CRITICAL TWO-STEP WORKFLOW ⚠️
74+
75+
When include_content=false (CURRENT repository):
76+
Step 1: codebase_search returns RELEVANT file paths + line numbers
77+
Step 2: You MUST Read() those files at those line numbers
78+
79+
❌ COMMON MISTAKE: Receiving search results then NOT reading the files
80+
✅ CORRECT BEHAVIOR: Search results are POINTERS - always follow up with Read
81+
82+
Search results are HIGHLY RELEVANT matches found by semantic search.
83+
If you receive file paths and line numbers, you MUST read those locations
84+
to get the actual code content. DO NOT ignore or skip search results.
85+
7386
CRITICAL RULE - When to include content:
7487
- CURRENT repository (user's working directory): include_content=false
7588
→ You have file access via Read tool - get paths only, then read for latest content
89+
→ Search gives you WHERE to look, Read gives you WHAT is there
7690
- EXTERNAL repositories (not in working directory): include_content=true
7791
→ You cannot access files - must get content in search results
7892
@@ -108,27 +122,40 @@ async def codebase_search(
108122
Search results as JSON including source info, file paths, line numbers, and code snippets.
109123
110124
Examples:
111-
1. Search CURRENT repository (identified by directory name + context):
125+
1. Search CURRENT repository (TWO-STEP workflow - ALWAYS follow search with Read):
112126
# Working in "/Users/bob/codealive-mcp"
113127
# User asks: "Where is the search tool implemented in this project?"
114128
# Repo name from get_data_sources: "codealive-mcp"
115129
# → Name matches directory, user says "this project" → CURRENT
130+
131+
# STEP 1: Get relevant file locations
116132
codebase_search(
117133
query="Where is the search tool implemented?",
118134
data_sources=["codealive-mcp"],
119-
include_content=false # Current repo - get paths, use Read tool
135+
include_content=false # Current repo - get paths only
120136
)
121-
# Then: Read(file_path="/Users/bob/codealive-mcp/src/tools/search.py")
137+
# Returns: {"results": [{"file": "src/tools/search.py", "line": 17, ...}]}
138+
139+
# STEP 2: MUST READ the files returned in search results
140+
# ⚠️ DO NOT SKIP THIS STEP - search results are RELEVANT matches!
141+
Read(file_path="/Users/bob/codealive-mcp/src/tools/search.py")
142+
# Now you have the actual current content to answer the question
122143
123144
2. Search CURRENT repository (identified by description matching):
124145
# Working in Python FastMCP project
125146
# Description: "Python MCP server using FastMCP framework"
126147
# You've been reading FastMCP code in this directory → CURRENT
148+
149+
# STEP 1: Search for relevant code
127150
codebase_search(
128151
query="How is the lifespan context managed?",
129152
data_sources=["my-mcp-server"],
130153
include_content=false # Description matches observed codebase
131154
)
155+
# Returns: [{"file": "src/server.py", "line": 45, ...}, ...]
156+
157+
# STEP 2: Read each relevant file from search results
158+
Read(file_path="src/server.py") # Get current content at the relevant lines
132159
133160
3. Search EXTERNAL repository (different service):
134161
# Working in "frontend-app"

0 commit comments

Comments
 (0)