Skip to main content
Glama
fix_fastmcp_debug.shโ€ข2.24 kB
#!/bin/bash # Fix FastMCP ServerErrorMiddleware debug warnings # Run this script after pip updates to reapply the debug=False hack # Compatible with Ubuntu/Linux and macOS echo "๐Ÿ”ง Fixing FastMCP debug mode to suppress ServerErrorMiddleware warnings..." # Try to find Python executable (try python3 first, then python) PYTHON_CMD="" if command -v python3 &> /dev/null; then PYTHON_CMD="python3" elif command -v python &> /dev/null; then PYTHON_CMD="python" else echo "โŒ No Python executable found. Install Python first." exit 1 fi echo "๐Ÿ“ Using Python: $PYTHON_CMD" # Find FastMCP installation path FASTMCP_PATH=$($PYTHON_CMD -c "import fastmcp; print(fastmcp.__file__)" 2>/dev/null | sed 's/__init__.py$//') if [ -z "$FASTMCP_PATH" ]; then echo "โŒ FastMCP not found. Make sure it's installed." echo " Try: pip install fastmcp" exit 1 fi echo "๐Ÿ“‚ FastMCP found at: $FASTMCP_PATH" SERVER_FILE="${FASTMCP_PATH}server/server.py" if [ ! -f "$SERVER_FILE" ]; then echo "โŒ FastMCP server.py not found at $SERVER_FILE" exit 1 fi # Create backup if it doesn't exist if [ ! -f "${SERVER_FILE}.backup" ]; then echo "๐Ÿ“‹ Creating backup of original server.py..." cp "$SERVER_FILE" "${SERVER_FILE}.backup" fi # Check if hack is already applied if grep -q "debug=False" "$SERVER_FILE"; then echo "โœ… FastMCP debug hack already applied!" exit 0 fi # Apply the hack (Linux-compatible sed syntax) echo "๐Ÿ”จ Applying debug=False hack..." # Detect OS for sed syntax if [[ "$OSTYPE" == "darwin"* ]]; then # macOS sed -i '' 's/debug=self\.settings\.debug/debug=False/g' "$SERVER_FILE" else # Linux/Ubuntu sed -i 's/debug=self\.settings\.debug/debug=False/g' "$SERVER_FILE" fi # Verify the change if grep -q "debug=False" "$SERVER_FILE"; then echo "โœ… FastMCP debug hack applied successfully!" echo "๐Ÿš€ ServerErrorMiddleware warnings should now be suppressed." echo "" echo "๐Ÿ“ Modified file: $SERVER_FILE" echo "" echo "To restore original behavior, run:" echo "cp '${SERVER_FILE}.backup' '$SERVER_FILE'" else echo "โŒ Failed to apply hack. Check the file manually." echo "๐Ÿ“ Target file: $SERVER_FILE" exit 1 fi

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MadnessEngineering/fastmcp-todo-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server