- Introduce environment variables for Cursor compatibility in silent-mcp.sh and npx-entry.cjs - Implement process cleanup for existing MCP instances to prevent conflicts - Adjust logging behavior based on execution context to ensure proper message handling - Add test-cursor.sh script to simulate Cursor environment for testing purposes - Refactor stdio-server.ts to manage logging and message flushing based on compatibility mode
25 lines
880 B
Bash
Executable File
25 lines
880 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Ensure we're running in a clean environment for MCP
|
|
# Set silent environment variables
|
|
export LOG_LEVEL=silent
|
|
export USE_STDIO_TRANSPORT=true
|
|
|
|
# Explicitly mark that we are NOT in Cursor mode
|
|
export CURSOR_COMPATIBLE=false
|
|
|
|
# Flag to prevent recursive execution
|
|
export SILENT_MCP_RUNNING=true
|
|
|
|
# Clean up any existing processes - optional but can help with "already" errors
|
|
# pkill -f "node.*stdio-server" >/dev/null 2>&1 || true
|
|
|
|
# Direct execution - always use local file
|
|
if [ -f "./dist/stdio-server.js" ]; then
|
|
# Keep stdout intact (for JSON-RPC messages) but redirect stderr to /dev/null
|
|
node ./dist/stdio-server.js 2>/dev/null
|
|
else
|
|
# If no local file, run directly through node using the globally installed package
|
|
# This avoids calling npx again which would create a loop
|
|
node $(npm root -g)/homeassistant-mcp/dist/stdio-server.js 2>/dev/null
|
|
fi |