-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·53 lines (44 loc) · 1.59 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# Smoke test for a locally running server: initialize a session, then call search_web.
# Override the defaults as needed, e.g. TOKEN=<your-diffbot-token> ./test.sh
set -uo pipefail
URL="${URL:-http://127.0.0.1:8000/mcp}"
TOKEN="${TOKEN:-TEST}"
ENDPOINT="$URL?token=$TOKEN"
# -L so the request survives the trailing-slash redirect fastmcp applies to /mcp/
curl_mcp() {
curl -sL \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
"$@"
}
# initialize and capture session ID
SESSION=$(curl_mcp -D - \
-d '{"jsonrpc":"2.0","id":0,"method":"initialize",
"params":{"protocolVersion":"2025-06-18",
"capabilities":{"tools":{}},
"clientInfo":{"name":"curl","version":"1"}}}' \
"$ENDPOINT" |
grep -i '^mcp-session-id' | awk '{print $2}' | tr -d '\r')
if [ -z "$SESSION" ]; then
echo "FAIL: no session ID returned from $URL — is the server running?" >&2
exit 1
fi
# send initialized notification
curl_mcp \
-H "Mcp-Session-Id: $SESSION" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
"$ENDPOINT"
# call the search tool
RESPONSE=$(curl_mcp \
-H "Mcp-Session-Id: $SESSION" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"search_web","arguments":{"query":"diffbot"}}}' \
"$ENDPOINT")
echo "$RESPONSE"
# the server reports tool failures in-band, so a 200 alone does not mean success
if [ -z "$RESPONSE" ] || echo "$RESPONSE" | grep -q '"isError":true'; then
echo "FAIL: search_web did not return a successful result" >&2
exit 1
fi
echo "PASS: search_web returned a result"