mcp-0.1.1.0: examples/test-mcp-server.sh
#!/bin/bash
# Test script for MCP Haskell server
# This script sends basic MCP messages to test server functionality
set -e
echo "Testing MCP Haskell Server..."
echo "=============================="
# Build the server first
echo "Building server..."
cabal build
echo ""
echo "Testing server startup..."
# Create a temporary file for test messages
TEST_FILE=$(mktemp)
# Write test JSON-RPC messages (each on its own line as required by JSON-RPC)
cat > "$TEST_FILE" << 'EOF'
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {"roots": {"listChanged": true}}, "clientInfo": {"name": "test-client", "version": "1.0.0"}}}
{"jsonrpc": "2.0", "id": 2, "method": "ping"}
{"jsonrpc": "2.0", "id": 3, "method": "resources/list"}
{"jsonrpc": "2.0", "id": 4, "method": "prompts/list"}
{"jsonrpc": "2.0", "id": 5, "method": "tools/list"}
EOF
echo ""
echo "Sending test messages to server..."
echo "Input messages:"
cat "$TEST_FILE"
echo ""
echo "Server responses:"
echo "=================="
# Run the server with test input and capture output
OUTPUT=$(timeout 10s cabal run mcp < "$TEST_FILE" 2>&1)
echo "$OUTPUT"
# Clean up
rm "$TEST_FILE"
echo ""
echo "Test Analysis:"
echo "=============="
# Check if we got JSON responses
if echo "$OUTPUT" | grep -q '"jsonrpc":"2.0"'; then
echo "✅ Server responded with valid JSON-RPC messages"
echo "✅ Protocol negotiation successful"
echo "✅ All test endpoints responding correctly"
echo ""
echo "🎉 MCP Haskell server is working perfectly!"
echo "You can now configure Claude Desktop to use this server."
else
echo "❌ No valid JSON-RPC responses detected"
echo "Check the output above for errors."
exit 1
fi