#!/bin/bash # Wait for HAProxy and MCP to be ready sleep 5 # Initialize MCP session INIT_RESPONSE=$(curl -s -i -X POST "http://localhost:8000/mcp" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"cli","version":"1.0"}},"id":0}' 2>/dev/null) SESSION_ID=$(echo "$INIT_RESPONSE" | grep -i "mcp-session-id" | cut -d' ' -f2 | tr -d '\r') if [ -z "$SESSION_ID" ]; then echo "Failed to get MCP session" exit 1 fi # Restore state curl -s -X POST "http://localhost:8000/mcp" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Mcp-Session-Id: $SESSION_ID" \ -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"haproxy_restore_state","arguments":{}},"id":1}' echo "" echo "State restored at $(date)"