CURL_TEST_COMMANDS.md•5.19 kB
# cURL Test Commands for All MCP Tools
## Prerequisites
- Server must be running: `npm run start`
- For GitHub tools: Ensure `.env` has `GITHUB_PERSONAL_ACCESS_TOKEN` set
## Quick Test: Server Status
```bash
curl http://localhost:3001/mcp/status
```
## Quick Test: List All Tools
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
```
---
## Tool 1: mark_attendance
```bash
curl -X POST http://localhost:3001/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": 1
}'
```
**Expected:** `{"jsonrpc":"2.0","result":{"content":[{"type":"text","text":"Attendance for 12345 on 2024-01-15: present"}]},"id":1}`
---
## Tool 2: get_repo_info
```bash
curl -X POST http://localhost:3001/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": 2
}'
```
**Expected:** Repository information with name, owner, default branch, stars, forks, etc.
---
## Tool 3: list_branches
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list_branches",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "github_sdk"
}
},
"id": 3
}'
```
**Expected:** List of all branches in the repository with their SHAs.
---
## Tool 4: create_branch
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_branch",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "github_sdk",
"branchName": "test-branch-123",
"baseBranch": "main"
}
},
"id": 4
}'
```
**Expected:** Success message confirming branch creation.
**Note:** This will create a new branch in your repository!
---
## Tool 5: get_file_contents
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_file_contents",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "github_sdk",
"filePath": "README.md",
"branch": "main"
}
},
"id": 5
}'
```
**Expected:** File contents with metadata (size, SHA, content).
---
## Tool 6: list_commits
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list_commits",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "github_sdk",
"branch": "main",
"perPage": 10
}
},
"id": 6
}'
```
**Expected:** List of recent commits with SHA, message, author, date, and URL.
---
## Tool 7: commit_changes
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "commit_changes",
"arguments": {
"repoOwner": "sadaf987",
"repoName": "github_sdk",
"branchName": "main",
"commitMessage": "Test commit from MCP server",
"filesToCommit": [
{
"path": "test.txt",
"content": "Hello from MCP server!"
}
]
}
},
"id": 5
}'
```
**Expected:** Success message confirming file commit.
**Note:** This will commit a file to your repository!
---
## Test All Tools at Once
Run the comprehensive test script:
```bash
./test-all-tools.sh
```
This will test all 5 tools in sequence.
---
## Pretty Print JSON Output
Add `| jq .` to any command for formatted output:
```bash
curl -X POST http://localhost:3001/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}' | jq .
```
(Requires `jq`: `sudo apt install jq`)
---
## Testing Order Recommendation
1. **mark_attendance** - No external dependencies, always works
2. **get_repo_info** - Read-only, safe to test
3. **list_branches** - Read-only, safe to test
4. **create_branch** - Creates a branch (test carefully)
5. **commit_changes** - Commits files (test carefully)
---
## Troubleshooting
### If tools return errors:
1. Check server is running: `curl http://localhost:3001/mcp/status`
2. Check GitHub token in `.env` file
3. Verify repository exists and you have access
4. Check server console logs for detailed errors
### Common Errors:
- **"Bad credentials"** - GitHub token is invalid or expired
- **"Not found"** - Repository doesn't exist or you don't have access
- **"Resource not accessible"** - Token doesn't have required permissions