Initial commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,192 @@
|
||||
@echo off
|
||||
REM MCP Python Project Manager - Windows Startup Script
|
||||
REM Save as: start-server.bat
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Configuration
|
||||
set PROJECT_DIR=C:\Users\dimir\proects\mcp-python
|
||||
set VENV_DIR=%PROJECT_DIR%\.venv
|
||||
set PYTHON_EXE=%VENV_DIR%\Scripts\python.exe
|
||||
|
||||
REM Parse arguments
|
||||
set TRANSPORT=stdio
|
||||
set DEBUG=false
|
||||
set WORKSPACE=
|
||||
set USE_UVX=false
|
||||
|
||||
:parse_args
|
||||
if "%~1"=="" goto :end_parse
|
||||
if /i "%~1"=="--debug" (
|
||||
set DEBUG=true
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if /i "%~1"=="--sse" (
|
||||
set TRANSPORT=sse
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if /i "%~1"=="--workspace" (
|
||||
set WORKSPACE=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if /i "%~1"=="--uvx" (
|
||||
set USE_UVX=true
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if /i "%~1"=="--help" (
|
||||
goto :show_help
|
||||
)
|
||||
shift
|
||||
goto :parse_args
|
||||
:end_parse
|
||||
|
||||
echo ========================================
|
||||
echo MCP Python Project Manager Server
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
REM Check if using uvx mode
|
||||
if "%USE_UVX%"=="true" (
|
||||
goto :run_with_uvx
|
||||
)
|
||||
|
||||
REM Traditional Python mode
|
||||
|
||||
REM Check if Python is available
|
||||
where python >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Python not found in PATH
|
||||
echo Please install Python 3.10+ from https://python.org
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Check/create virtual environment
|
||||
if not exist "%PYTHON_EXE%" (
|
||||
echo [INFO] Creating virtual environment...
|
||||
python -m venv "%VENV_DIR%"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Failed to create virtual environment
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM Activate virtual environment
|
||||
call "%VENV_DIR%\Scripts\activate.bat"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Failed to activate virtual environment
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Install dependencies if needed
|
||||
if not exist "%VENV_DIR%\Lib\site-packages\mcp" (
|
||||
echo [INFO] Installing dependencies...
|
||||
pip install -r "%PROJECT_DIR%\requirements.txt"
|
||||
if errorlevel 1 (
|
||||
echo [WARNING] Some dependencies may have failed to install
|
||||
)
|
||||
)
|
||||
|
||||
REM Set environment variables
|
||||
set MCP_PYTHON_WORKSPACE=%WORKSPACE:C:/Users/dimir/projects=%
|
||||
if "%DEBUG%"=="true" (
|
||||
set MCP_PYTHON_DEBUG=true
|
||||
set MCP_PYTHON_LOG_LEVEL=DEBUG
|
||||
echo [DEBUG] Debug mode enabled
|
||||
)
|
||||
|
||||
REM Build command
|
||||
set SERVER_CMD=%PYTHON_EXE% "%PROJECT_DIR%\server.py" --transport %TRANSPORT%
|
||||
if "%WORKSPACE%" neq "" (
|
||||
set SERVER_CMD=!SERVER_CMD! --workspace "%WORKSPACE%"
|
||||
)
|
||||
if "%DEBUG%"=="true" (
|
||||
set SERVER_CMD=!SERVER_CMD! --debug
|
||||
)
|
||||
|
||||
echo [INFO] Starting server with %TRANSPORT% transport...
|
||||
echo [INFO] Workspace: %MCP_PYTHON_WORKSPACE%
|
||||
echo [INFO] Press Ctrl+C to stop the server
|
||||
echo.
|
||||
|
||||
REM Run server
|
||||
%SERVER_CMD%
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
|
||||
REM Deactivate virtual environment
|
||||
deactivate
|
||||
|
||||
goto :exit_handler
|
||||
|
||||
:run_with_uvx
|
||||
REM Check if uv/uvx is available
|
||||
where uvx >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] uvx not found in PATH
|
||||
echo Please install uv: winget install astral-sh.uv
|
||||
echo or: pip install uv
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [INFO] Running with uvx (no venv needed!)...
|
||||
|
||||
REM Build uvx command
|
||||
set UVX_CMD=uvx --from "%PROJECT_DIR%" mcp-python-manager --transport %TRANSPORT%
|
||||
if "%WORKSPACE%" neq "" (
|
||||
set UVX_CMD=!UVX_CMD! --workspace "%WORKSPACE%"
|
||||
)
|
||||
if "%DEBUG%"=="true" (
|
||||
set UVX_CMD=!UVX_CMD! --debug
|
||||
set UV_NO_CACHE=0
|
||||
)
|
||||
|
||||
set MCP_PYTHON_WORKSPACE=%WORKSPACE:C:/Users/dimir/projects=%
|
||||
echo [INFO] Workspace: %MCP_PYTHON_WORKSPACE%
|
||||
echo [INFO] Press Ctrl+C to stop the server
|
||||
echo.
|
||||
|
||||
REM Run server with uvx
|
||||
%UVX_CMD%
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
|
||||
:exit_handler
|
||||
if %EXIT_CODE% equ 0 (
|
||||
echo.
|
||||
echo [INFO] Server stopped normally
|
||||
) else (
|
||||
echo.
|
||||
echo [ERROR] Server exited with code %EXIT_CODE%
|
||||
)
|
||||
|
||||
pause
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:show_help
|
||||
echo Usage: start-server.bat [options]
|
||||
echo.
|
||||
echo Options:
|
||||
echo --debug Enable debug logging
|
||||
echo --sse Use SSE transport instead of stdio
|
||||
echo --workspace Set custom workspace directory
|
||||
echo --uvx Use uvx instead of python/venv (recommended)
|
||||
echo --help Show this help message
|
||||
echo.
|
||||
echo Examples:
|
||||
echo start-server.bat
|
||||
echo start-server.bat --debug
|
||||
echo start-server.bat --sse --port 8080
|
||||
echo start-server.bat --workspace "D:\MyProjects"
|
||||
echo start-server.bat --uvx --debug ^(Recommended!^)
|
||||
echo.
|
||||
echo Prerequisites for --uvx:
|
||||
echo Install uv: winget install astral-sh.uv
|
||||
echo or: pip install uv
|
||||
exit /b 0
|
||||
Reference in New Issue
Block a user