test-server.sh•2.24 kB
#!/bin/bash
# Simple bash script to test the MCP server using curl and named pipes
# This simulates the JSON-RPC communication over stdin/stdout
echo "🚀 Starting Google Slides MCP Server Test"
echo "=========================================="
# Check if the server is built
if [ ! -f "dist/index.js" ]; then
echo "❌ Server not built. Running 'npm run build'..."
npm run build
fi
# Create named pipes for communication
PIPE_IN=$(mktemp -u)
PIPE_OUT=$(mktemp -u)
mkfifo "$PIPE_IN"
mkfifo "$PIPE_OUT"
# Start the MCP server in background
echo "🔧 Starting MCP server..."
node dist/index.js < "$PIPE_IN" > "$PIPE_OUT" &
SERVER_PID=$!
# Function to send JSON-RPC request
send_request() {
local request="$1"
local description="$2"
echo ""
echo "📤 $description"
echo "Request: $request"
# Send request
echo "$request" > "$PIPE_IN"
# Read response
timeout 5 cat "$PIPE_OUT" | head -n 1
}
# Function to cleanup
cleanup() {
echo ""
echo "🧹 Cleaning up..."
kill $SERVER_PID 2>/dev/null
rm -f "$PIPE_IN" "$PIPE_OUT"
exit
}
# Set up cleanup on script exit
trap cleanup EXIT INT TERM
# Wait a moment for server to start
sleep 2
# Test sequence
echo "🔄 Testing MCP server functionality..."
# 1. Initialize connection
send_request '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {"tools": {}}, "clientInfo": {"name": "bash-test", "version": "1.0.0"}}}' "Initializing connection"
# 2. List tools
send_request '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}' "Listing available tools"
# 3. Get auth URL
send_request '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "get_auth_url", "arguments": {}}}' "Getting authentication URL"
echo ""
echo "✅ Basic server functionality test completed!"
echo ""
echo "📋 Next steps for full testing:"
echo "1. Visit the authentication URL shown above"
echo "2. Complete the OAuth flow and get an authorization code"
echo "3. Run the interactive test client: node test-client.js"
echo "4. Or continue with manual JSON-RPC calls using the auth code"
echo ""
echo "💡 For detailed testing instructions, see TESTING.md"