test-all-tools.sh•5.1 kB
#!/bin/bash
# Comprehensive test script for all MCP tools
BASE_URL="http://localhost:3001"
echo "=========================================="
echo "Testing All MCP Tools"
echo "=========================================="
echo ""
# Test 1: Check server status
echo "1. Server Status"
echo "----------------------------------------"
curl -s "$BASE_URL/mcp/status" | jq .
echo ""
echo ""
# Test 2: List available tools
echo "2. List All Available Tools"
echo "----------------------------------------"
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}' | jq '.result.tools[].name'
echo ""
echo ""
# Test 3: mark_attendance
echo "3. Testing mark_attendance"
echo "----------------------------------------"
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "mark_attendance",
"arguments": {
"studentId": "12345",
"date": "2024-01-15",
"status": "present"
}
},
"id": 2
}' | jq .
echo ""
echo ""
# Test 4: get_repo_info
echo "4. Testing get_repo_info"
echo "----------------------------------------"
echo "Note: Update repoOwner and repoName in the script"
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_repo_info",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "test_MCP"
}
},
"id": 3
}' | jq .
echo ""
echo ""
# Test 5: list_branches
echo "5. Testing list_branches"
echo "----------------------------------------"
echo "Note: Update repoOwner and repoName in the script"
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list_branches",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "test_MCP"
}
},
"id": 4
}' | jq .
echo ""
echo ""
# Test 6: create_branch
echo "6. Testing create_branch"
echo "----------------------------------------"
echo "Note: Update repoOwner, repoName, and branchName in the script"
echo "Warning: This will create a new branch!"
read -p "Continue? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_branch",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "test_MCP",
"branchName": "test-branch-'$(date +%s)'",
"baseBranch": "main"
}
},
"id": 5
}' | jq .
else
echo "Skipped"
fi
echo ""
echo ""
# Test 7: get_file_contents
echo "7. Testing get_file_contents"
echo "----------------------------------------"
echo "Note: Update repoOwner, repoName, and filePath in the script"
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_file_contents",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "test_MCP",
"filePath": "README.md",
"branch": "main"
}
},
"id": 6
}' | jq .
echo ""
echo ""
# Test 8: list_commits
echo "8. Testing list_commits"
echo "----------------------------------------"
echo "Note: Update repoOwner and repoName in the script"
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list_commits",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "test_MCP",
"branch": "main
",
"perPage": 10
}
},
"id": 7
}' | jq .
echo ""
echo ""
# Test 9: commit_changes
echo "9. Testing commit_changes"
echo "----------------------------------------"
echo "Note: Update repoOwner, repoName, and ensure you have write access"
echo "Warning: This will commit a file to the repository!"
read -p "Continue? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
curl -s -X POST "$BASE_URL/mcp" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "commit_changes",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "test_MCP",
"branchName": "main",
"commitMessage": "Test commit from MCP server - all tools test",
"filesToCommit": [
{
"path": "test-mcp-tools.txt",
"content": "This file was created via MCP commit_changes tool\nTimestamp: '$(date)'"
}
]
}
},
"id": 8
}' | jq .
else
echo "Skipped"
fi
echo ""
echo ""
echo "=========================================="
echo "Testing Complete"
echo "=========================================="