Skip to content

Commit f59c185

Browse files
committed
chore: optimize MCP description
1 parent ecc43e2 commit f59c185

3 files changed

Lines changed: 2060 additions & 2036 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323

2424
dependencies = [
2525
"mcp>=1.0.0",
26-
"cocoindex[litellm]>=1.0.0a12",
26+
"cocoindex[litellm]>=1.0.0a13",
2727
"sentence-transformers>=2.2.0",
2828
"sqlite-vec>=0.1.0",
2929
"pydantic>=2.0.0",

src/cocoindex_code/server.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,16 @@
1111
# Initialize MCP server
1212
mcp = FastMCP(
1313
"cocoindex-code",
14-
instructions="""
15-
This server provides semantic code search for the codebase.
16-
This allows you to quickly and cheaply search for code related to a concept or functionality
17-
across the entire codebase.
18-
19-
Use the `search` tool when you need to:
20-
- Find code related to a concept or functionality
21-
- Search for implementations of specific features
22-
- Discover how something is done in the codebase
23-
- Find similar code patterns
24-
25-
The `search` tool has a `refresh_index` parameter (default: True) that refreshes
26-
the index before searching. Set it to False for consecutive queries to avoid
27-
redundant refreshes.
28-
29-
The search uses vector embeddings for semantic similarity, so you can describe
30-
what you're looking for in natural language rather than exact text matches.
31-
""".strip(),
14+
instructions=(
15+
"Code search and codebase understanding tools."
16+
"\n"
17+
"Use when you need to find code, understand how something works,"
18+
" locate implementations, or explore an unfamiliar codebase."
19+
"\n"
20+
"Provides semantic search that understands meaning --"
21+
" unlike grep or text matching,"
22+
" it finds relevant code even when exact keywords are unknown."
23+
),
3224
)
3325

3426
# Lock to prevent concurrent index updates
@@ -71,13 +63,28 @@ class SearchResultModel(BaseModel):
7163
@mcp.tool(
7264
name="search",
7365
description=(
74-
"Search the codebase using semantic similarity. "
75-
"Returns relevant code chunks with file locations and similarity scores. "
76-
"Use natural language queries or code snippets to find related code."
66+
"Semantic code search across the entire codebase"
67+
" -- finds code by meaning, not just text matching."
68+
" Use this instead of grep/glob when you need to find implementations,"
69+
" understand how features work,"
70+
" or locate related code without knowing exact names or keywords."
71+
" Accepts natural language queries"
72+
" (e.g., 'authentication logic', 'database connection handling')"
73+
" or code snippets."
74+
" Returns matching code chunks with file paths,"
75+
" line numbers, and relevance scores."
7776
),
7877
)
7978
async def search(
80-
query: str = Field(description="Natural language query or code snippet to search for"),
79+
query: str = Field(
80+
description=(
81+
"Natural language query or code snippet to search for."
82+
" Examples: 'error handling middleware',"
83+
" 'how are users authenticated',"
84+
" 'database connection pool',"
85+
" or paste a code snippet to find similar code."
86+
)
87+
),
8188
limit: int = Field(
8289
default=10,
8390
ge=1,
@@ -92,8 +99,9 @@ async def search(
9299
refresh_index: bool = Field(
93100
default=True,
94101
description=(
95-
"Whether to refresh the index before querying. "
96-
"Set to False for consecutive queries to skip redundant refreshes."
102+
"Whether to incrementally update the index before searching."
103+
" Set to False for faster consecutive queries"
104+
" when the codebase hasn't changed."
97105
),
98106
),
99107
) -> SearchResultModel:

0 commit comments

Comments
 (0)