test_remote_mcp_curl.shโข2.62 kB
#!/bin/bash
# Test remote MCP server with direct curl commands
echo "๐งช Testing Remote MCP Server with curl"
echo "======================================\n"
# Read configuration from .env.local
if [ ! -f ".env.local" ]; then
echo "โ ERROR: .env.local file not found"
echo " Please run ./setup.sh to configure the environment"
exit 1
fi
# Source the environment file and get the host
source .env.local
if [ -z "$DATABRICKS_HOST" ]; then
echo "โ ERROR: DATABRICKS_HOST not set in .env.local"
exit 1
fi
if [ -z "$DATABRICKS_APP_NAME" ]; then
echo "โ ERROR: DATABRICKS_APP_NAME not set in .env.local"
exit 1
fi
echo "Getting app URL from Databricks Apps API..."
# Get the app URL dynamically using the Databricks CLI with environment variables
export DATABRICKS_HOST
export DATABRICKS_TOKEN
APP_INFO=$(uvx databricks apps list 2>/dev/null | grep "^${DATABRICKS_APP_NAME}" || true)
if [ -z "$APP_INFO" ]; then
echo "โ ERROR: App '${DATABRICKS_APP_NAME}' not found in Databricks Apps"
echo " Please deploy the app first with: ./deploy.sh"
exit 1
fi
# Extract the URL from the app info (second column in tabular output)
REMOTE_URL=$(echo "$APP_INFO" | awk '{print $2}')
if [ -z "$REMOTE_URL" ]; then
echo "โ ERROR: Could not extract app URL from: $APP_INFO"
exit 1
fi
echo "โ
Found app URL: $REMOTE_URL"
echo "Getting OAuth token from Databricks CLI..."
TOKEN=$(uvx databricks auth token --host "${DATABRICKS_HOST}" 2>/dev/null | jq -r '.access_token')
if [ "$TOKEN" = "null" ] || [ -z "$TOKEN" ]; then
echo "โ ERROR: Failed to get OAuth token"
echo " Please run: uvx databricks auth login --host ${DATABRICKS_HOST}"
exit 1
fi
echo "โ
Got OAuth token\n"
echo "1. Test OAuth authentication and headers:"
RESPONSE=$(curl -s "${REMOTE_URL}/mcp/" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${TOKEN}")
if echo "$RESPONSE" | grep -q "Missing session ID"; then
echo "โ
OAuth authentication accepted, server requires MCP session (expected)"
else
echo "โ Unexpected response: $RESPONSE"
fi
echo "\n"
echo "2. Test direct tools/list (requires MCP session):"
curl -s -X POST "${REMOTE_URL}/mcp/" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${TOKEN}" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | jq '.'
echo "\n"
echo "โน๏ธ Note: Direct curl requires full MCP session initialization."
echo " Use the proxy test for complete MCP protocol compliance."
echo "\n"
echo "โ
Remote MCP curl tests complete"