-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_example_01.sh
More file actions
executable file
·48 lines (38 loc) · 1.4 KB
/
test_example_01.sh
File metadata and controls
executable file
·48 lines (38 loc) · 1.4 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
#!/bin/bash
# Test script for example_01_hello_world
echo "🧪 Testing Example 01: Hello World MCP Server"
echo "=============================================="
# Build the example
echo "📦 Building example..."
cargo build --bin example_01_hello_world --quiet
if [ $? -ne 0 ]; then
echo "❌ Build failed!"
exit 1
fi
echo "✅ Build successful!"
# Test 1: List tools
echo ""
echo "🔍 Test 1: Listing available tools"
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | timeout 5s cargo run --bin example_01_hello_world --quiet > /tmp/test1_output.json 2>/dev/null
if [ $? -eq 0 ]; then
echo "✅ tools/list test passed"
echo "📄 Response:"
cat /tmp/test1_output.json | jq '.' 2>/dev/null || cat /tmp/test1_output.json
else
echo "❌ tools/list test failed"
fi
# Test 2: Call greeting tool
echo ""
echo "🔍 Test 2: Calling greeting tool"
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"greeting","arguments":{"name":"Rust Developer"}}}' | timeout 5s cargo run --bin example_01_hello_world --quiet > /tmp/test2_output.json 2>/dev/null
if [ $? -eq 0 ]; then
echo "✅ greeting tool test passed"
echo "📄 Response:"
cat /tmp/test2_output.json | jq '.' 2>/dev/null || cat /tmp/test2_output.json
else
echo "❌ greeting tool test failed"
fi
# Cleanup
rm -f /tmp/test1_output.json /tmp/test2_output.json
echo ""
echo "🎉 Example 01 testing completed!"