test-mcp-server.shโข3.79 kB
#!/bin/zsh
# Colors for terminal output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo "${CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo "${CYAN}โ MCP Server Testing Suite โ${NC}"
echo "${CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}\n"
echo "${BLUE}๐ Testing MCP Server Implementation...${NC}\n"
# Check if server is running
if ! lsof -i :3000 | grep LISTEN > /dev/null; then
echo "${RED}โ Server not running on port 3000${NC}"
echo "${YELLOW}Start it with: ./start.sh${NC}\n"
exit 1
fi
echo "${GREEN}โ
Server is running on port 3000${NC}\n"
# Test 1: List Tools (GET)
echo "${BLUE}๐ Test 1: List Available Tools${NC}"
echo "${YELLOW}GET /mcp/tools/list${NC}"
echo ""
RESPONSE=$(curl -s http://localhost:3000/mcp/tools/list)
if [ $? -eq 0 ]; then
echo "${GREEN}โ
Success!${NC}"
echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"
else
echo "${RED}โ Failed to get tools list${NC}"
fi
echo ""
# Test 2: Call Tool (POST)
echo "${BLUE}๐ง Test 2: Call topMovers Tool${NC}"
echo "${YELLOW}POST /mcp/tools/call${NC}"
echo ""
RESPONSE=$(curl -s -X POST http://localhost:3000/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{"name":"topMovers","arguments":{"limit":3}}')
if [ $? -eq 0 ]; then
echo "${GREEN}โ
Success!${NC}"
echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"
else
echo "${RED}โ Failed to call tool${NC}"
fi
echo ""
# Test 3: Frontend
echo "${BLUE}๐ Test 3: Frontend Access${NC}"
echo "${YELLOW}GET /${NC}"
echo ""
RESPONSE=$(curl -s -I http://localhost:3000/ | head -1)
if echo "$RESPONSE" | grep -q "200 OK"; then
echo "${GREEN}โ
Frontend accessible!${NC}"
echo "${BLUE}Open: http://localhost:3000${NC}"
else
echo "${RED}โ Frontend not accessible${NC}"
fi
echo ""
# Test 4: MCP Protocol (if available)
echo "${BLUE}๐ Test 4: MCP Protocol Server${NC}"
echo "${YELLOW}Testing stdio MCP server...${NC}"
echo ""
if [ -f "test-mcp-protocol.js" ]; then
echo "${BLUE}Running MCP protocol test...${NC}"
node test-mcp-protocol.js
else
echo "${YELLOW}โ ๏ธ MCP protocol test script not found${NC}"
echo "${YELLOW} Run: node test-mcp-protocol.js${NC}"
fi
echo ""
# Summary
echo "${CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo "${CYAN}โ Test Summary โ${NC}"
echo "${CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}\n"
echo "${GREEN}โ
Your server implements:${NC}"
echo " ${BLUE}โข Express REST API${NC} (for ChatGPT/web)"
echo " ${BLUE}โข MCP Protocol Server${NC} (for MCP clients)"
echo " ${BLUE}โข Beautiful Frontend${NC} (DaisyUI + Tailwind)"
echo " ${BLUE}โข Real-time Data${NC} (Alpha Vantage API)"
echo ""
echo "${YELLOW}๐ Available Endpoints:${NC}"
echo " ${BLUE}GET /${NC} โ Frontend UI"
echo " ${BLUE}GET /mcp/tools/list${NC} โ List MCP tools"
echo " ${BLUE}POST /mcp/tools/call${NC} โ Execute MCP tools"
echo ""
echo "${YELLOW}๐งช Test Commands:${NC}"
echo " ${BLUE}curl http://localhost:3000/mcp/tools/list${NC}"
echo " ${BLUE}curl -X POST http://localhost:3000/mcp/tools/call \\${NC}"
echo " ${BLUE} -H 'Content-Type: application/json' \\${NC}"
echo " ${BLUE} -d '{\"name\":\"topMovers\",\"arguments\":{\"limit\":3}}'${NC}"
echo ""