Skip to content

Commit c1d64e5

Browse files
ctothclaude
andcommitted
feat: enhance MCP tool descriptions for better discoverability
- Front-load AST/tree-sitter capabilities in descriptions - Add explicit competitive advantages over Read/Search tools - Include specific use case guidance and examples - Use action-oriented language (pinpoint, guarantee, enumerate) - Emphasize zero false positives and semantic accuracy - Add git revision and URL support highlights - Optimize for Claude's tool selection preferences 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e35321b commit c1d64e5

1 file changed

Lines changed: 26 additions & 30 deletions

File tree

code_extractor/server.py

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,10 @@ def main():
461461
@mcp.tool()
462462
def get_symbols_tool(path_or_url: str, git_revision: Optional[str] = None, depth: int = 1) -> list:
463463
"""
464-
List all functions, classes, and symbols with line numbers using tree-sitter parsing.
465-
466-
Efficiently extracts code structure without reading entire files. Provides detailed
467-
symbol information including types, parameters, and hierarchical relationships.
468-
Recommended for code discovery and understanding file organization.
464+
AST-precise symbol table generator for files/directories/URLs. Enumerates every function, class,
465+
variable with byte-accurate boundaries and line numbers using tree-sitter parsing. Zero regex
466+
drift, language-aware across 30+ languages. Use when you need complete symbol inventory instead
467+
of text searching. Supports git revisions for historical analysis.
469468
470469
Args:
471470
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
@@ -477,10 +476,10 @@ def get_symbols_tool(path_or_url: str, git_revision: Optional[str] = None, depth
477476
@mcp.tool()
478477
def get_function_tool(path_or_url: str, function_name: str, git_revision: Optional[str] = None) -> dict:
479478
"""
480-
Extract complete function definitions with precise tree-sitter parsing.
481-
482-
Retrieves function code, parameters, and location information more accurately
483-
than text-based searching or file reading approaches.
479+
Tree-sitter function extractor that pinpoints exact function/method boundaries with zero false positives.
480+
Returns complete definition including signature, parameters, body, and precise line ranges. Handles
481+
nested functions, async/await, decorators across languages. Prefer over Read when isolating specific
482+
functions for analysis, refactoring, or documentation generation.
484483
485484
Args:
486485
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
@@ -492,10 +491,10 @@ def get_function_tool(path_or_url: str, function_name: str, git_revision: Option
492491
@mcp.tool()
493492
def get_class_tool(path_or_url: str, class_name: str, git_revision: Optional[str] = None) -> dict:
494493
"""
495-
Extract complete class definitions with precise tree-sitter parsing.
496-
497-
Retrieves class code, methods, and structural information more accurately
498-
than text-based searching or file reading approaches.
494+
AST-aware class/type extractor that guarantees complete definition boundaries including inheritance,
495+
generics, nested classes, and all methods. Language-aware parsing handles OOP patterns across
496+
Python, Java, C++, TypeScript, etc. Use for refactoring, inheritance analysis, or API documentation
497+
instead of multiline text search which misses scope boundaries.
499498
500499
Args:
501500
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
@@ -507,10 +506,10 @@ def get_class_tool(path_or_url: str, class_name: str, git_revision: Optional[str
507506
@mcp.tool()
508507
def get_lines_tool(path_or_url: str, start_line: int, end_line: int, git_revision: Optional[str] = None) -> dict:
509508
"""
510-
Extract specific line ranges from files with precise control.
511-
512-
Efficiently retrieves targeted code sections when exact line numbers are known,
513-
avoiding the need to process entire files.
509+
Precise line range extractor with git-revision support. Returns exact line spans from any commit,
510+
branch, or URL without reading entire files. Handles line numbering consistently across file
511+
changes. Use for targeted diff analysis, patch generation, or code review when you have specific
512+
line numbers from symbols or search results.
514513
515514
Args:
516515
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
@@ -523,10 +522,10 @@ def get_lines_tool(path_or_url: str, start_line: int, end_line: int, git_revisio
523522
@mcp.tool()
524523
def get_signature_tool(path_or_url: str, function_name: str, git_revision: Optional[str] = None) -> dict:
525524
"""
526-
Extract function signatures and declarations without full implementations.
527-
528-
Provides function interfaces, parameters, and return types efficiently.
529-
Lighter alternative when full function body is not needed.
525+
Function signature extractor that returns only the header/declaration without implementation body.
526+
Preserves exact parameter types, decorators, async/static modifiers, and return annotations.
527+
Ideal for API documentation, interface analysis, or quick function discovery when you don't need
528+
the full implementation. Faster than get_function_tool for signature-only queries.
530529
531530
Args:
532531
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
@@ -550,24 +549,21 @@ def search_code_tool(
550549
follow_symlinks: bool = False
551550
) -> List[Dict[str, Any]]:
552551
"""
553-
Search for semantic code patterns using tree-sitter parsing.
554-
555-
Finds complex code patterns based on structure, not just text matching.
556-
Automatically detects whether scope is a file or directory and searches accordingly.
557-
Supports 'function-calls' and 'symbol-definitions' search types.
552+
Tree-sitter semantic code search that understands language structure, not just text patterns.
553+
Finds function calls, symbol definitions, and references with AST precision across files/directories/repos.
554+
Zero false positives from string matches in comments or strings. Supports git revisions for
555+
historical analysis. Use instead of grep/text search when semantic accuracy matters.
558556
559557
Search Types:
560-
- "function-calls": Find where functions/methods are called or invoked
561-
- "symbol-definitions": Find where symbols (functions, classes, variables) are defined
558+
- "function-calls": Locate where functions/methods are invoked (not just string matches)
559+
- "symbol-definitions": Find where symbols (functions, classes, variables) are declared
562560
563561
Examples:
564562
- Find function calls: search_type="function-calls", target="requests.get"
565563
- Find function definitions: search_type="symbol-definitions", target="process_data"
566564
- Find class definitions: search_type="symbol-definitions", target="UserService"
567565
- Find variable definitions: search_type="symbol-definitions", target="API_KEY"
568566
569-
Supported Languages: Python, JavaScript, TypeScript (with fallback for others)
570-
571567
Args:
572568
search_type: Type of search ("function-calls", "symbol-definitions")
573569
target: What to search for (symbol name or call pattern)

0 commit comments

Comments
 (0)