| 1 | #!/usr/bin/env bash |
| 2 | # Smoke-test the siGit MCP endpoint with raw JSON-RPC over curl. |
| 3 | # Usage: BASE=https://sigit.si TOKEN=<pat> ./script/smoke.sh |
| 4 | set -euo pipefail |
| 5 | |
| 6 | BASE="${BASE:-http://localhost:3000}" |
| 7 | URL="$BASE/api/v1/mcp" |
| 8 | TOKEN="${TOKEN:?set TOKEN to a siGit personal access token}" |
| 9 | |
| 10 | post() { |
| 11 | curl -sS -X POST "$URL" \ |
| 12 | -H "Authorization: Bearer $TOKEN" \ |
| 13 | -H "Content-Type: application/json" \ |
| 14 | -H "Accept: application/json, text/event-stream" \ |
| 15 | -d "$1" |
| 16 | echo |
| 17 | } |
| 18 | |
| 19 | echo "== initialize ==" |
| 20 | post '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}' |
| 21 | |
| 22 | echo "== notifications/initialized (expect empty 202) ==" |
| 23 | curl -sS -o /dev/null -w "HTTP %{http_code}\n" -X POST "$URL" \ |
| 24 | -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ |
| 25 | -d '{"jsonrpc":"2.0","method":"notifications/initialized"}' |
| 26 | |
| 27 | echo "== tools/list ==" |
| 28 | post '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' |
| 29 | |
| 30 | echo "== tools/call list_repositories ==" |
| 31 | post '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_repositories","arguments":{"limit":5}}}' |