Files

63 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke test for the Streamable HTTP MCP server.
# Verifies: /healthz, JSON-RPC initialize, tools/list.
#
# Usage:
# ./scripts/smoke-test.sh # against http://127.0.0.1:3000
# MCP_URL=https://mcp-wms.arthur-ria.fr ./scripts/smoke-test.sh
set -euo pipefail
MCP_URL="${MCP_URL:-http://127.0.0.1:3000}"
HOST_HEADER="${HOST_HEADER:-127.0.0.1:3000}"
red() { printf '\033[31m%s\033[0m\n' "$*"; }
green() { printf '\033[32m%s\033[0m\n' "$*"; }
info() { printf '\033[36m%s\033[0m\n' "$*"; }
info "== 1. GET /healthz =="
curl --fail -sS "${MCP_URL}/healthz" | tee /dev/stderr | grep -q '"status":"ok"' \
&& green "healthz OK" || { red "healthz FAILED"; exit 1; }
echo
info "== 2. POST /mcp initialize =="
INIT_RESP=$(curl --fail -sS -X POST "${MCP_URL}/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Host: ${HOST_HEADER}" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": {"name": "smoke-test", "version": "0.0.1"}
}
}')
echo "$INIT_RESP"
echo "$INIT_RESP" | grep -q '"serverInfo"' \
&& green "initialize OK" || { red "initialize FAILED"; exit 1; }
echo
info "== 3. POST /mcp tools/list =="
TOOLS_RESP=$(curl --fail -sS -X POST "${MCP_URL}/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Host: ${HOST_HEADER}" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}')
echo "$TOOLS_RESP"
for tool in search_wiki get_wiki_page list_wiki_sections get_glossary_term get_related_pages; do
echo "$TOOLS_RESP" | grep -q "\"name\":\"${tool}\"" \
&& green " tool present: ${tool}" \
|| { red " MISSING tool: ${tool}"; exit 1; }
done
echo
green "All smoke checks passed."