Skip to content
7 changes: 6 additions & 1 deletion cycode/cli/apps/mcp/mcp_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uuid
from typing import Annotated, Any, Optional

import anyio
import typer
from pathvalidate import sanitize_filepath
from pydantic import Field
Expand Down Expand Up @@ -65,6 +66,7 @@ def _get_current_executable() -> str:
return 'cycode'


# ruff: disable[ASYNC109]
async def _run_cycode_command(*args: str, timeout: int = _DEFAULT_RUN_COMMAND_TIMEOUT) -> dict[str, Any]:
"""Run a cycode command asynchronously and return the parsed result.
Expand Down Expand Up @@ -109,6 +111,9 @@ async def _run_cycode_command(*args: str, timeout: int = _DEFAULT_RUN_COMMAND_TI
return {'error': f'Failed to run command: {e!s}'}


# ruff: enable[ASYNC109]


def _sanitize_file_path(file_path: str) -> str:
"""Sanitize file path to prevent path traversal and other security issues.
Expand Down Expand Up @@ -238,7 +243,7 @@ async def _cycode_scan_tool(

try:
if paths:
missing = [p for p in paths if not os.path.exists(p)]
missing = [p for p in paths if not await anyio.Path(p).exists()]
if missing:
return json.dumps({'error': f'Paths not found on disk: {missing}'}, indent=2)

Expand Down
Loading
Loading