0.3.0 Release Version

This commit is contained in:
FreeOnePlus
2025-06-08 18:44:40 +08:00
parent d9fed06c92
commit 4c913743c7
54 changed files with 12649 additions and 4667 deletions

View File

@@ -1,99 +1,81 @@
#!/bin/bash
# Doris MCP Server Start Script
# Ensures the service runs in SSE mode
# Doris MCP Server Start Script (Streamable HTTP Mode)
# Ensures the service runs in Streamable HTTP mode for web-based MCP clients
# Set colors
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}========== Doris MCP Server Start Script ==========${NC}"
echo -e "${GREEN}========== Doris MCP Server Start Script (HTTP Mode) ==========${NC}"
# Check virtual environment
if [ -d "venv" ]; then
echo -e "${CYAN}Virtual environment found, activating...${NC}" # Found virtual environment, activating...
if [ -d ".venv" ]; then
echo -e "${CYAN}Virtual environment found, activating...${NC}"
source .venv/bin/activate
elif [ -d "venv" ]; then
echo -e "${CYAN}Virtual environment found, activating...${NC}"
source venv/bin/activate
else
echo -e "${YELLOW}Warning: No virtual environment found${NC}"
fi
# Clean cache files
echo -e "${CYAN}Cleaning cache files...${NC}" # Cleaning cache files...
echo -e "${CYAN}Cleaning Python cache files...${NC}" # Cleaning Python cache files...
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
echo -e "${CYAN}Cleaning temporary files...${NC}" # Cleaning temporary files...
echo -e "${CYAN}Cleaning cache files...${NC}"
echo -e "${CYAN}Cleaning Python cache files...${NC}"
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
echo -e "${CYAN}Cleaning temporary files...${NC}"
rm -rf .pytest_cache 2>/dev/null || true
echo -e "${CYAN}Cleaning log files...${NC}" # Cleaning log files...
find ./log -type f -name "*.log" -delete 2>/dev/null || true
echo -e "${CYAN}Cleaning log files...${NC}"
find ./logs -type f -name "*.log" -delete 2>/dev/null || true
# Create necessary directories
mkdir -p logs
mkdir -p tmp
# Reload environment variables
if [ -f .env ]; then
echo -e "${CYAN}Loading environment variables from .env file...${NC}" # Loading environment variables from .env file...
echo -e "${CYAN}Loading environment variables from .env file...${NC}"
set -a # automatically export all variables
source .env
set +a # stop automatically exporting
else
echo -e "${YELLOW}Warning: .env file not found${NC}"
fi
# Output key environment variables before starting
echo -e "${CYAN}Database settings:${NC}" # Database settings:
echo "DB_HOST=${DB_HOST}"
echo "DB_PORT=${DB_PORT}"
echo "DB_DATABASE=${DB_DATABASE}"
echo "FORCE_REFRESH_METADATA=${FORCE_REFRESH_METADATA}"
# Start the server (using -m and new package path)
python -m doris_mcp_server.main --sse
# Clean cache files (This section seems redundant and possibly misplaced after the server starts)
echo -e "${YELLOW}Cleaning cache files...${NC}" # Cleaning cache files...
# Backend cache cleanup
echo -e "${GREEN}Cleaning Python cache files...${NC}" # Cleaning Python cache files...
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
rm -rf ./.pytest_cache
# Clean temporary files
echo -e "${GREEN}Cleaning temporary files...${NC}" # Cleaning temporary files...
rm -rf ./tmp
mkdir -p tmp
# Clean log files
echo -e "${GREEN}Cleaning log files...${NC}" # Cleaning log files...
rm -rf ./logs/*.log
mkdir -p logs
# Set environment variables, force SSE mode (This section also seems redundant if variables are set in .env and the command uses --sse)
export MCP_PORT=3000
export ALLOWED_ORIGINS="*"
export LOG_LEVEL="info"
export MCP_ALLOW_CREDENTIALS="false"
# Set HTTP-specific environment variables
export MCP_TRANSPORT_TYPE="http"
export MCP_HOST="${MCP_HOST:-0.0.0.0}"
export MCP_PORT="${MCP_PORT:-3000}"
export ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-*}"
export LOG_LEVEL="${LOG_LEVEL:-info}"
export MCP_ALLOW_CREDENTIALS="${MCP_ALLOW_CREDENTIALS:-false}"
# Add adapter debug support
export MCP_DEBUG_ADAPTER="true"
export PYTHONPATH="$(pwd):$PYTHONPATH" # Ensure modules can be imported
export PYTHONPATH="$(pwd):$PYTHONPATH"
# Create log directory
mkdir -p logs
echo -e "${GREEN}Starting MCP server (Streamable HTTP mode)...${NC}"
echo -e "${YELLOW}Service will run on http://${MCP_HOST}:${MCP_PORT}/mcp${NC}"
echo -e "${YELLOW}Health Check: http://${MCP_HOST}:${MCP_PORT}/health${NC}"
echo -e "${YELLOW}MCP Endpoint: http://${MCP_HOST}:${MCP_PORT}/mcp${NC}"
echo -e "${YELLOW}Local access: http://localhost:${MCP_PORT}/mcp${NC}"
echo -e "${YELLOW}Use Ctrl+C to stop the service${NC}"
# Debug info
echo -e "${GREEN}Environment Variables:${NC}" # Environment Variables:
echo -e "MCP_TRANSPORT_TYPE=${MCP_TRANSPORT_TYPE}"
echo -e "MCP_PORT=${MCP_PORT}"
echo -e "ALLOWED_ORIGINS=${ALLOWED_ORIGINS}"
echo -e "LOG_LEVEL=${LOG_LEVEL}"
echo -e "MCP_ALLOW_CREDENTIALS=${MCP_ALLOW_CREDENTIALS}"
echo -e "MCP_DEBUG_ADAPTER=${MCP_DEBUG_ADAPTER}"
# Start the server in HTTP mode (Streamable HTTP)
python -m doris_mcp_server.main --transport http --host ${MCP_HOST} --port ${MCP_PORT}
echo -e "${GREEN}Starting MCP server (SSE mode)...${NC}" # Starting MCP server (SSE mode)...
echo -e "${YELLOW}Service will run on http://localhost:3000/mcp${NC}" # Service will run on http://localhost:3000/mcp
echo -e "${YELLOW}Health Check: http://localhost:3000/health${NC}" # Health Check: http://localhost:3000/health
echo -e "${YELLOW}SSE Test: http://localhost:3000/sse${NC}" # SSE Test: http://localhost:3000/sse
echo -e "${YELLOW}Use Ctrl+C to stop the service${NC}" # Use Ctrl+C to stop the service
# If the server exits abnormally, output error message
# Check exit status
if [ $? -ne 0 ]; then
echo -e "${RED}Server exited abnormally! Check logs for more information${NC}" # Server exited abnormally! Check logs for more information
echo -e "${RED}Server exited abnormally! Check logs for more information${NC}"
exit 1
fi
# Show browser cache clearing prompt
echo -e "${YELLOW}Tip: If the page displays abnormally, please clear your browser cache or use incognito mode${NC}" # Tip: If the page displays abnormally, please clear your browser cache or use incognito mode
echo -e "${YELLOW}Chrome browser clear cache shortcut: Ctrl+Shift+Del (Windows) or Cmd+Shift+Del (Mac)${NC}" # Chrome browser clear cache shortcut: Ctrl+Shift+Del (Windows) or Cmd+Shift+Del (Mac)
# Show usage tips
echo -e "${YELLOW}Tip: If the page displays abnormally, please clear your browser cache or use incognito mode${NC}"
echo -e "${YELLOW}Chrome browser clear cache shortcut: Ctrl+Shift+Del (Windows) or Cmd+Shift+Del (Mac)${NC}"
echo -e "${CYAN}For testing HTTP endpoints, you can use:${NC}"
echo -e "${CYAN} curl -X POST http://localhost:${MCP_PORT}/mcp -H 'Content-Type: application/json' -d '{\"method\":\"tools/list\"}'${NC}"