Skip to content

Commit 29c6c2d

Browse files
authored
Merge pull request #17 from GitHubSecurityLab/large_file
exit gracefully with large file
2 parents a690c2a + 69d127f commit 29c6c2d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/seclab_taskflows/mcp_servers/local_file_viewer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
LOCAL_GH_DIR = mcp_data_dir('seclab-taskflows', 'local_file_viewer', 'LOCAL_GH_DIR')
2626

27+
LINE_LIMIT_FOR_FETCHING_FILE_CONTENT = int(os.getenv('LINE_LIMIT_FOR_FETCHING_FILE_CONTENT', default=1000))
28+
2729
def is_subdirectory(directory, potential_subdirectory):
2830
directory_path = Path(directory)
2931
potential_subdirectory_path = Path(potential_subdirectory)
@@ -106,6 +108,8 @@ async def fetch_file_content(
106108
if not source_path or not source_path.exists():
107109
return f"Invalid {owner} and {repo}. Check that the input is correct or try to fetch the repo from gh first."
108110
lines = get_file(source_path, path)
111+
if len(lines) > LINE_LIMIT_FOR_FETCHING_FILE_CONTENT:
112+
return f"File {path} in {owner}/{repo} is too large to display ({len(lines)} lines). Please fetch specific lines using get_file_lines tool."
109113
if not lines:
110114
return f"Unable to find file {path} in {owner}/{repo}"
111115
for i in range(len(lines)):

src/seclab_taskflows/toolboxes/local_file_viewer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ server_params:
1111
args: ["-m", "seclab_taskflows.mcp_servers.local_file_viewer"]
1212
env:
1313
LOCAL_GH_DIR: "{{ env DATA_DIR }}"
14+
LINE_LIMIT_FOR_FETCHING_FILE_CONTENT: "{{ env LINE_LIMIT_FOR_FETCHING_FILE_CONTENT }}"

0 commit comments

Comments
 (0)