Skip to content

Commit d69ee5c

Browse files
committed
feat: update MCP tool interfaces to use path_or_url with URL examples
1 parent 3f9cb73 commit d69ee5c

1 file changed

Lines changed: 41 additions & 20 deletions

File tree

code_extractor/server.py

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def main():
429429
mcp = FastMCP("extract")
430430

431431
@mcp.tool()
432-
def get_symbols_tool(file_path: str, git_revision: Optional[str] = None) -> list:
432+
def get_symbols_tool(path_or_url: str, git_revision: Optional[str] = None) -> list:
433433
"""
434434
🚨 **ALWAYS USE THIS FIRST** for code investigation - DO NOT use Read()!
435435
@@ -438,13 +438,18 @@ def get_symbols_tool(file_path: str, git_revision: Optional[str] = None) -> list
438438
DON'T read entire files to understand code structure - use this instead.
439439
440440
Args:
441-
file_path: Path to the source file
442-
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.)
441+
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
442+
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.) - not supported for URLs
443+
444+
Examples:
445+
get_symbols_tool("/path/to/file.py") # Local file
446+
get_symbols_tool("https://raw.githubusercontent.com/user/repo/main/file.py") # GitHub raw URL
447+
get_symbols_tool("/path/to/file.py", "HEAD~1") # Git revision
443448
"""
444-
return get_symbols(file_path, git_revision)
449+
return get_symbols(path_or_url, git_revision)
445450

446451
@mcp.tool()
447-
def get_function_tool(file_path: str, function_name: str, git_revision: Optional[str] = None) -> dict:
452+
def get_function_tool(path_or_url: str, function_name: str, git_revision: Optional[str] = None) -> dict:
448453
"""
449454
Extract function definition - USE THIS INSTEAD OF Read() for specific functions!
450455
@@ -453,14 +458,18 @@ def get_function_tool(file_path: str, function_name: str, git_revision: Optional
453458
If you're looking for a specific function, this is better than searching.
454459
455460
Args:
456-
file_path: Path to the source file
461+
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
457462
function_name: Name of the function to extract
458-
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.)
463+
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.) - not supported for URLs
464+
465+
Examples:
466+
get_function_tool("/path/to/file.py", "my_function") # Local file
467+
get_function_tool("https://raw.githubusercontent.com/user/repo/main/file.py", "my_function") # GitHub raw URL
459468
"""
460-
return find_function(None)(file_path, function_name, git_revision)
469+
return find_function(None)(path_or_url, function_name, git_revision)
461470

462471
@mcp.tool()
463-
def get_class_tool(file_path: str, class_name: str, git_revision: Optional[str] = None) -> dict:
472+
def get_class_tool(path_or_url: str, class_name: str, git_revision: Optional[str] = None) -> dict:
464473
"""
465474
Extract class definition - USE THIS INSTEAD OF Read() for specific classes!
466475
@@ -469,40 +478,52 @@ def get_class_tool(file_path: str, class_name: str, git_revision: Optional[str]
469478
If you're looking for a specific class, this is better than searching.
470479
471480
Args:
472-
file_path: Path to the source file
481+
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
473482
class_name: Name of the class to extract
474-
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.)
483+
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.) - not supported for URLs
484+
485+
Examples:
486+
get_class_tool("/path/to/file.py", "MyClass") # Local file
487+
get_class_tool("https://raw.githubusercontent.com/user/repo/main/file.py", "MyClass") # GitHub raw URL
475488
"""
476-
return find_class(None)(file_path, class_name, git_revision)
489+
return find_class(None)(path_or_url, class_name, git_revision)
477490

478491
@mcp.tool()
479-
def get_lines_tool(file_path: str, start_line: int, end_line: int, git_revision: Optional[str] = None) -> dict:
492+
def get_lines_tool(path_or_url: str, start_line: int, end_line: int, git_revision: Optional[str] = None) -> dict:
480493
"""
481494
Get specific lines from a file using precise line range control.
482495
483496
Use when you know exact line numbers - better than reading entire files.
484497
485498
Args:
486-
file_path: Path to the source file
499+
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
487500
start_line: Starting line number (1-based)
488501
end_line: Ending line number (1-based, inclusive)
489-
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.)
502+
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.) - not supported for URLs
503+
504+
Examples:
505+
get_lines_tool("/path/to/file.py", 10, 20) # Local file lines 10-20
506+
get_lines_tool("https://raw.githubusercontent.com/user/repo/main/file.py", 1, 50) # GitHub raw URL
490507
"""
491-
return get_lines(file_path, start_line, end_line, git_revision)
508+
return get_lines(path_or_url, start_line, end_line, git_revision)
492509

493510
@mcp.tool()
494-
def get_signature_tool(file_path: str, function_name: str, git_revision: Optional[str] = None) -> dict:
511+
def get_signature_tool(path_or_url: str, function_name: str, git_revision: Optional[str] = None) -> dict:
495512
"""
496513
Get just the signature/declaration of a function without full implementation.
497514
498515
Use for function interfaces, parameters, return types. Lighter than get_function.
499516
500517
Args:
501-
file_path: Path to the source file
518+
path_or_url: Path to source file or URL (GitHub raw, GitLab raw, direct file URL)
502519
function_name: Name of the function to get signature for
503-
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.)
520+
git_revision: Optional git revision (commit, branch, tag, HEAD~1, etc.) - not supported for URLs
521+
522+
Examples:
523+
get_signature_tool("/path/to/file.py", "my_function") # Local file
524+
get_signature_tool("https://raw.githubusercontent.com/user/repo/main/file.py", "my_function") # GitHub raw URL
504525
"""
505-
return get_signature(file_path, function_name, git_revision)
526+
return get_signature(path_or_url, function_name, git_revision)
506527

507528
# Run the server
508529
mcp.run()

0 commit comments

Comments
 (0)