Skip to main content
Glama
baptitse-jn

LinkedIn MCP Server

by baptitse-jn
start_linkedin.shβ€’8.33 kB
#!/bin/bash # LinkedIn MCP Client Startup Script # Starts both the Netlify MCP server and LinkedIn FastAPI client set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Configuration SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROCESSES_DIR="$SCRIPT_DIR/.processes" NETLIFY_PORT=8888 FASTAPI_PORT=8002 # Create processes directory mkdir -p "$PROCESSES_DIR" echo -e "${BLUE}πŸš€ Starting LinkedIn MCP Infrastructure${NC}" echo "==================================" # Function to check if port is in use check_port() { local port=$1 if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then return 0 else return 1 fi } # Function to start Netlify dev server start_netlify() { echo -e "${YELLOW}πŸ“‘ Starting Netlify MCP Server...${NC}" if check_port $NETLIFY_PORT; then echo -e "${YELLOW}⚠️ Port $NETLIFY_PORT already in use. Checking if it's our server...${NC}" # Test if it's responding to MCP requests if curl -s -X POST http://localhost:$NETLIFY_PORT/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"mcp/init","params":{},"id":"1"}' \ | grep -q "linkedin-mcp-server"; then echo -e "${GREEN}βœ… LinkedIn MCP Server already running on port $NETLIFY_PORT${NC}" return 0 else echo -e "${RED}❌ Port $NETLIFY_PORT in use by different service${NC}" return 1 fi fi cd "$PROJECT_ROOT" # Start Netlify dev server in background nohup npx netlify dev --port=$NETLIFY_PORT > "$PROCESSES_DIR/netlify-dev.log" 2>&1 & NETLIFY_PID=$! echo $NETLIFY_PID > "$PROCESSES_DIR/netlify.pid" echo -e "${BLUE}πŸ“‹ Netlify PID: $NETLIFY_PID${NC}" # Wait for server to start echo -e "${YELLOW}⏳ Waiting for Netlify server to start...${NC}" for i in {1..30}; do if curl -s http://localhost:$NETLIFY_PORT >/dev/null 2>&1; then echo -e "${GREEN}βœ… Netlify server started successfully${NC}" return 0 fi sleep 1 done echo -e "${RED}❌ Netlify server failed to start within 30 seconds${NC}" return 1 } # Function to start LinkedIn FastAPI client start_fastapi() { echo -e "${YELLOW}🐍 Starting LinkedIn FastAPI Client...${NC}" if check_port $FASTAPI_PORT; then echo -e "${YELLOW}⚠️ Port $FASTAPI_PORT already in use. Checking if it's our client...${NC}" # Test if it's our FastAPI client if curl -s http://localhost:$FASTAPI_PORT/ | grep -q "LinkedIn MCP Client"; then echo -e "${GREEN}βœ… LinkedIn FastAPI Client already running on port $FASTAPI_PORT${NC}" return 0 else echo -e "${RED}❌ Port $FASTAPI_PORT in use by different service${NC}" return 1 fi fi cd "$SCRIPT_DIR" # Check if virtual environment exists if [ ! -d ".venv" ]; then echo -e "${YELLOW}πŸ“¦ Creating Python virtual environment...${NC}" python3 -m venv .venv fi # Activate virtual environment and install dependencies source .venv/bin/activate echo -e "${YELLOW}πŸ“¦ Installing/updating Python dependencies...${NC}" pip install -q --upgrade pip pip install -q -r requirements.txt # Start FastAPI server in background nohup python -m uvicorn linkedin_client:app --host 0.0.0.0 --port $FASTAPI_PORT --reload > "$PROCESSES_DIR/fastapi.log" 2>&1 & FASTAPI_PID=$! echo $FASTAPI_PID > "$PROCESSES_DIR/fastapi.pid" echo -e "${BLUE}πŸ“‹ FastAPI PID: $FASTAPI_PID${NC}" # Wait for server to start echo -e "${YELLOW}⏳ Waiting for FastAPI server to start...${NC}" for i in {1..20}; do if curl -s http://localhost:$FASTAPI_PORT/ >/dev/null 2>&1; then echo -e "${GREEN}βœ… FastAPI server started successfully${NC}" return 0 fi sleep 1 done echo -e "${RED}❌ FastAPI server failed to start within 20 seconds${NC}" return 1 } # Function to test the setup test_setup() { echo -e "${YELLOW}πŸ§ͺ Testing LinkedIn MCP setup...${NC}" # Test MCP server echo -e "${BLUE}Testing MCP server initialization...${NC}" MCP_RESPONSE=$(curl -s -X POST http://localhost:$NETLIFY_PORT/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"mcp/init","params":{},"id":"1"}') if echo "$MCP_RESPONSE" | grep -q "linkedin-mcp-server"; then echo -e "${GREEN}βœ… MCP server responding correctly${NC}" else echo -e "${RED}❌ MCP server not responding correctly${NC}" echo "Response: $MCP_RESPONSE" return 1 fi # Test FastAPI client echo -e "${BLUE}Testing FastAPI client health...${NC}" HEALTH_RESPONSE=$(curl -s http://localhost:$FASTAPI_PORT/health) if echo "$HEALTH_RESPONSE" | grep -q "healthy"; then echo -e "${GREEN}βœ… FastAPI client healthy${NC}" else echo -e "${YELLOW}⚠️ FastAPI client responding but may have issues${NC}" echo "Response: $HEALTH_RESPONSE" fi # Run quick test suite echo -e "${BLUE}Running quick test suite...${NC}" cd "$SCRIPT_DIR" if [ -f ".venv/bin/activate" ]; then source .venv/bin/activate python test_linkedin.py else echo -e "${YELLOW}⚠️ Virtual environment not found, skipping test suite${NC}" fi } # Main execution main() { # Check dependencies if ! command -v node >/dev/null 2>&1; then echo -e "${RED}❌ Node.js is required but not installed${NC}" exit 1 fi if ! command -v python3 >/dev/null 2>&1; then echo -e "${RED}❌ Python 3 is required but not installed${NC}" exit 1 fi if ! command -v npx >/dev/null 2>&1; then echo -e "${RED}❌ npx is required but not installed${NC}" exit 1 fi # Start services if start_netlify && start_fastapi; then echo -e "\n${GREEN}πŸŽ‰ LinkedIn MCP Infrastructure Started Successfully!${NC}" echo "==================================" echo -e "${BLUE}πŸ“Š Service URLs:${NC}" echo " β€’ MCP Server: http://localhost:$NETLIFY_PORT/mcp" echo " β€’ LinkedIn API: http://localhost:$FASTAPI_PORT" echo " β€’ API Documentation: http://localhost:$FASTAPI_PORT/docs" echo " β€’ ReDoc: http://localhost:$FASTAPI_PORT/redoc" echo "" echo -e "${BLUE}πŸ“‚ Log Files:${NC}" echo " β€’ Netlify: $PROCESSES_DIR/netlify-dev.log" echo " β€’ FastAPI: $PROCESSES_DIR/fastapi.log" echo "" echo -e "${BLUE}πŸ”§ Management Commands:${NC}" echo " β€’ Check Status: ./check_linkedin_status.sh" echo " β€’ Stop Services: ./stop_linkedin.sh" echo " β€’ Run Tests: python test_linkedin.py" echo "" # Test the setup test_setup echo -e "\n${GREEN}πŸš€ Ready for LinkedIn automation!${NC}" echo -e "${YELLOW}πŸ’‘ Set LINKEDIN_ACCESS_TOKEN environment variable for full functionality${NC}" else echo -e "\n${RED}πŸ’₯ Failed to start LinkedIn MCP Infrastructure${NC}" exit 1 fi } # Handle script arguments case "${1:-start}" in "start") main ;; "stop") echo -e "${YELLOW}πŸ›‘ Use ./stop_linkedin.sh to stop services${NC}" ;; "test") test_setup ;; "help") echo "LinkedIn MCP Infrastructure Management" echo "" echo "Usage: $0 [command]" echo "" echo "Commands:" echo " start (default) - Start all services" echo " test - Test running services" echo " help - Show this help" echo "" echo "Other scripts:" echo " ./stop_linkedin.sh - Stop all services" echo " ./check_linkedin_status.sh - Check service status" ;; *) echo -e "${RED}❌ Unknown command: $1${NC}" echo "Use '$0 help' for usage information" exit 1 ;; esac

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/baptitse-jn/linkedin_mcp'

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