#!/bin/bash
# Test script for MCP Elicitations feature
# This tests vendor creation using natural language
set -e # Exit on error
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Configuration
API_URL="http://localhost:8001/chat"
TOKEN="${BEARER_TOKEN:-your-token-here}"
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} MCP Elicitations Feature Test Suite${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Check if token is set
if [ "$TOKEN" = "your-token-here" ]; then
echo -e "${RED}ERROR: Please set BEARER_TOKEN environment variable${NC}"
echo "Usage: BEARER_TOKEN=your-token ./test_elicitations.sh"
exit 1
fi
# Test 1: Simple vendor creation
echo -e "${YELLOW}Test 1: Simple vendor creation${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Create a vendor called \"AutoParts Pro\" that sells car parts"}' | jq -r '.response' | head -20
echo ""
echo -e "${GREEN}✓ Test 1 completed${NC}"
echo ""
# Test 2: Vendor with contact info
echo -e "${YELLOW}Test 2: Vendor with contact information${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Add a tire vendor \"Tire World\" with contact John at 555-1234 and email sales@tireworld.com"}' | jq -r '.response' | head -20
echo ""
echo -e "${GREEN}✓ Test 2 completed${NC}"
echo ""
# Test 3: Vendor with location and website
echo -e "${YELLOW}Test 3: Vendor with location and website${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Create a vendor \"Joe'\''s Garage\" in Detroit, Michigan with website https://joesgarage.com"}' | jq -r '.response' | head -20
echo ""
echo -e "${GREEN}✓ Test 3 completed${NC}"
echo ""
# Test 4: Minimal information (should prompt for more)
echo -e "${YELLOW}Test 4: Minimal information (should prompt for more)${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Add a vendor"}' | jq -r '.response' | head -20
echo ""
echo -e "${GREEN}✓ Test 4 completed${NC}"
echo ""
# Test 5: Complex vendor description
echo -e "${YELLOW}Test 5: Complex vendor description${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "I want to create a new vendor called \"Premium Auto Supplies\". They specialize in high-end automotive accessories and are located in Los Angeles, California. Their contact person is Sarah Johnson and you can reach them at sarah@premiumauto.com or (310) 555-6789. Their website is https://premiumauto.com and they primarily work with luxury car dealerships."}' | jq -r '.response' | head -25
echo ""
echo -e "${GREEN}✓ Test 5 completed${NC}"
echo ""
# Test 6: Follow-up conversation (multi-turn)
echo -e "${YELLOW}Test 6: Multi-turn elicitation${NC}"
echo "First, provide minimal info..."
response1=$(curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Create a vendor called \"Quick Lube\""}' | jq -r '.response')
echo "$response1"
echo ""
# Check if follow-up is needed
if echo "$response1" | grep -q "need more information"; then
echo "Now provide the missing information..."
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Quick Lube is an oil change service located in Houston, Texas. Their phone is 713-555-9999 and email is info@quicklube.com"}' | jq -r '.response' | head -20
fi
echo ""
echo -e "${GREEN}✓ Test 6 completed${NC}"
echo ""
# Test 7: Test different formats for the result
echo -e "${YELLOW}Test 7: Vendor creation result as table${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Create a vendor called \"Battery Plus\" and show me the result as a table"}' | jq -r '.response' | head -20
echo ""
echo -e "${GREEN}✓ Test 7 completed${NC}"
echo ""
# Test 8: Vendor with billing info
echo -e "${YELLOW}Test 8: Vendor with billing information${NC}"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Create a vendor \"Fleet Services\" that requires contracts, billing type 2, department 3, and GL code 6005"}' | jq -r '.response' | head -20
echo ""
echo -e "${GREEN}✓ Test 8 completed${NC}"
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${GREEN} All elicitation tests completed!${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
echo -e "${YELLOW}What to look for in the results:${NC}"
echo " 1. Correct extraction of vendor names"
echo " 2. Proper parsing of contact information"
echo " 3. Follow-up prompts for missing data"
echo " 4. Successful vendor creation confirmations"
echo " 5. Proper error handling for incomplete data"
echo ""
echo -e "${YELLOW}Key Features Demonstrated:${NC}"
echo " ✅ Natural language vendor creation"
echo " ✅ Automatic data extraction"
echo " ✅ Missing field detection"
echo " ✅ Multi-turn conversations"
echo " ✅ Integration with sampling for formatting"
echo ""