test-mcp.shβ’2.45 kB
#!/bin/bash
# Test MCP Protocol Endpoints
# Run this after starting the dev server with: npm run dev
BASE_URL="http://localhost:8787"
echo "π§ͺ Testing MCP Protocol Endpoints"
echo "=================================="
echo ""
# Test 1: Initialize connection
echo "1οΈβ£ Testing initialize..."
curl -s -X POST $BASE_URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "test-client",
"version": "1.0.0"
}
}
}' | jq '.'
echo ""
# Test 2: List available tools
echo "2οΈβ£ Testing tools/list..."
curl -s -X POST $BASE_URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}' | jq '.'
echo ""
# Test 3: Call echo_message tool
echo "3οΈβ£ Testing tools/call - echo_message..."
curl -s -X POST $BASE_URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "echo_message",
"arguments": {
"message": "Hello from MCP test!"
}
}
}' | jq '.'
echo ""
# Test 4: Call why_are_we_yelling tool
echo "4οΈβ£ Testing tools/call - why_are_we_yelling..."
curl -s -X POST $BASE_URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "why_are_we_yelling",
"arguments": {
"text": "this will be loud"
}
}
}' | jq '.'
echo ""
# Test 5: Call query_json tool
echo "5οΈβ£ Testing tools/call - query_json..."
curl -s -X POST $BASE_URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "query_json",
"arguments": {
"filter": ".users[] | select(.age > 25)",
"data": {
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 20},
{"name": "Charlie", "age": 35}
]
}
}
}
}' | jq '.'
echo ""
echo "β
MCP protocol tests complete!"
echo ""
echo "π MCP Methods Tested:"
echo " β’ initialize - Establish MCP connection"
echo " β’ tools/list - Get available tools"
echo " β’ tools/call - Invoke tools with arguments"