diff --git a/src/seclab_taskflows/mcp_servers/gh_file_viewer.py b/src/seclab_taskflows/mcp_servers/gh_file_viewer.py index f138a43..ea9a40c 100644 --- a/src/seclab_taskflows/mcp_servers/gh_file_viewer.py +++ b/src/seclab_taskflows/mcp_servers/gh_file_viewer.py @@ -126,6 +126,9 @@ async def fetch_file_from_gh( """ Fetch the content of a file from a GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + r = await call_api( url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}", params={} @@ -146,6 +149,9 @@ async def get_file_lines_from_gh( length: int = Field(description="The ending line number to fetch from the file", default=10)) -> str: """Fetch a range of lines from a file in a GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + r = await call_api( url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}", params={} @@ -171,6 +177,9 @@ async def search_file_from_gh( """ Search for a term in a file from a GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + r = await call_api( url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}", params={} @@ -193,6 +202,9 @@ async def search_files_from_gh( """ Search for a term in a list of files from a GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + paths_list = [path.strip() for path in paths.split(',')] if not paths_list: return "No paths provided for search." @@ -238,6 +250,9 @@ async def list_directory_from_gh( """ Fetch the content of a directory from a GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + r = await call_api( url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}", params={} @@ -259,6 +274,9 @@ async def search_repo_from_gh( """ Search for the search term in the entire repository. """ + owner = owner.lower() + repo = repo.lower() + with tempfile.TemporaryDirectory() as tmp_dir: result = await _fetch_source_zip(owner, repo, tmp_dir) source_path = Path(f"{tmp_dir}/{owner}/{repo}.zip") diff --git a/src/seclab_taskflows/mcp_servers/local_file_viewer.py b/src/seclab_taskflows/mcp_servers/local_file_viewer.py index 1e3c170..4dd73bc 100644 --- a/src/seclab_taskflows/mcp_servers/local_file_viewer.py +++ b/src/seclab_taskflows/mcp_servers/local_file_viewer.py @@ -111,6 +111,9 @@ async def fetch_file_content( """ Fetch the content of a file from a local GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR]) if not source_path or not source_path.exists(): @@ -133,6 +136,9 @@ async def get_file_lines( length: int = Field(description="The ending line number to fetch from the file", default=10)) -> str: """Fetch a range of lines from a file in a local GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR]) if not source_path or not source_path.exists(): @@ -155,6 +161,9 @@ async def list_files( """ Recursively list the files of a directory from a local GitHub repository. """ + owner = owner.lower() + repo = repo.lower() + source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR]) if not source_path or not source_path.exists(): @@ -173,6 +182,9 @@ async def list_files_non_recursive( List the files of a directory from a local GitHub repository non-recursively. Subdirectories will be listed and indicated with a trailing slash. """ + owner = owner.lower() + repo = repo.lower() + source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR]) if not source_path or not source_path.exists(): @@ -191,6 +203,9 @@ async def search_repo( """ Search for the search term in the repository or a subdirectory/file in the repository. """ + owner = owner.lower() + repo = repo.lower() + source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR]) if not source_path or not source_path.exists(): diff --git a/src/seclab_taskflows/mcp_servers/local_gh_resources.py b/src/seclab_taskflows/mcp_servers/local_gh_resources.py index 6c3b17c..3c48ad6 100644 --- a/src/seclab_taskflows/mcp_servers/local_gh_resources.py +++ b/src/seclab_taskflows/mcp_servers/local_gh_resources.py @@ -95,6 +95,9 @@ async def fetch_repo_from_gh( """ Download the source code from GitHub to the local file system to speed up file search. """ + owner = owner.lower() + repo = repo.lower() + result = await _fetch_source_zip(owner, repo, LOCAL_GH_DIR) source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") if not source_path.exists(): @@ -106,6 +109,9 @@ async def clear_local_repo(owner: str, repo: str): """ Delete the local repo. """ + owner = owner.lower() + repo = repo.lower() + source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip") source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR]) if not source_path: