Validate workspace path is a directory in cursor install (#3426) (#3435)

This commit is contained in:
Jeremiah Lowin 2026-03-07 11:40:33 -05:00 committed by GitHub
commit fadb630142
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View file

@ -91,6 +91,9 @@ def install_cursor_workspace(
if not workspace_path.exists():
print(f"[red]Workspace directory does not exist: {workspace_path}[/red]")
return False
if not workspace_path.is_dir():
print(f"[red]Workspace path is not a directory: {workspace_path}[/red]")
return False
# Create .cursor directory in workspace
cursor_dir = workspace_path / ".cursor"

View file

@ -9,6 +9,7 @@ from fastmcp.cli.install.cursor import (
cursor_command,
generate_cursor_deeplink,
install_cursor,
install_cursor_workspace,
open_deeplink,
)
from fastmcp.mcp_config import StdioMCPServer
@ -356,6 +357,20 @@ class TestInstallCursor:
# Verify failure message was printed
mock_print.assert_called()
def test_install_cursor_workspace_path_is_file(self, tmp_path):
"""Test that passing a file as workspace_path returns False."""
file_path = tmp_path / "somefile.txt"
file_path.write_text("hello")
result = install_cursor_workspace(
file=Path("/path/to/server.py"),
server_object=None,
name="test-server",
workspace_path=file_path,
)
assert result is False
def test_install_cursor_deduplicate_packages(self):
"""Test that duplicate packages are deduplicated."""
with patch("fastmcp.cli.install.cursor.open_deeplink") as mock_open: