Skip to main content
Glama

School Attendance MCP Server

by Sadaf987
CURL_TESTING.md7.37 kB
# Alternative Ways to Test MCP Tools ## Method 1: Direct cURL Commands (Already Available) ### Test Server Status ```bash curl http://localhost:3001/mcp/status ``` ### Test Tools List ```bash curl -X POST http://localhost:3001/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "tools/list", "id": 1 }' ``` ### Test mark_attendance Tool ```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": 2 }' ``` ### Test commit_changes Tool ```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": "test_MCP", "branchName": "main", "commitMessage": "Test commit from MCP", "filesToCommit": [ { "path": "test.txt", "content": "Hello from MCP server!" } ] } }, "id": 3 }' ``` ### Test get_repo_info Tool ```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": "github_sdk " } }, "id": 4 }' ``` ## Method 2: Use Test Scripts (Already Available) ### Run All Tests ```bash ./test-tools.sh ``` ### Test Specific Tool ```bash ./test-commit.sh ./test-get-repo-info.sh ``` ## Method 3: Direct Function Calls (Node.js Script) Create a test file `test-direct.js`: ```javascript import { markAttendance } from './src/tools/attendanceTools.js'; import { commitChanges, getRepoInfo } from './src/tools/githubTools.js'; import 'dotenv/config'; // Test mark_attendance async function testMarkAttendance() { console.log('Testing mark_attendance...'); const result = await markAttendance({ studentId: '12345', date: '2024-01-15', status: 'present' }); console.log('Result:', result); } // Test get_repo_info async function testGetRepoInfo() { console.log('Testing get_repo_info...'); const result = await getRepoInfo({ repoOwner: 'sadaf987', repoName: 'test_MCP' }); console.log('Result:', result); } // Test commit_changes async function testCommitChanges() { console.log('Testing commit_changes...'); const result = await commitChanges({ repoOwner: 'sadaf987', repoName: 'test_MCP', branchName: 'main', commitMessage: 'Test commit from direct call', filesToCommit: [ { path: 'test-direct.txt', content: 'This file was created via direct function call' } ] }); console.log('Result:', result); } // Run tests async function runTests() { try { await testMarkAttendance(); console.log('\n---\n'); await testGetRepoInfo(); console.log('\n---\n'); // Uncomment to test commit (requires valid GitHub token) // await testCommitChanges(); } catch (error) { console.error('Error:', error); } } runTests(); ``` Run it: ```bash node --loader ts-node/esm test-direct.js # or tsx test-direct.js ``` ## Method 4: Using Postman or HTTP Client ### Setup 1. **Method**: POST 2. **URL**: `http://localhost:3001/mcp` 3. **Headers**: - `Content-Type: application/json` ### Request Body Examples **List Tools:** ```json { "jsonrpc": "2.0", "method": "tools/list", "id": 1 } ``` **Call Tool:** ```json { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "mark_attendance", "arguments": { "studentId": "12345", "date": "2024-01-15", "status": "present" } }, "id": 2 } ``` ## Method 5: Using MCP Inspector (Official Tool) Install MCP Inspector: ```bash npm install -g @modelcontextprotocol/inspector ``` Run inspector: ```bash npx @modelcontextprotocol/inspector ``` Note: This might require stdio transport, which our server doesn't support yet. ## Method 6: Simple Node.js Test Script Create `test-simple.js`: ```javascript import fetch from 'node-fetch'; const MCP_URL = 'http://localhost:3001/mcp'; async function callTool(toolName, arguments) { const response = await fetch(MCP_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', params: { name: toolName, arguments }, id: Date.now() }) }); const data = await response.json(); return data.result; } // Test async function test() { console.log('Testing mark_attendance...'); const result1 = await callTool('mark_attendance', { studentId: '12345', date: '2024-01-15', status: 'present' }); console.log('Result:', result1); console.log('\nTesting get_repo_info...'); const result2 = await callTool('get_repo_info', { repoOwner: 'sadaf987', repoName: 'test_MCP' }); console.log('Result:', result2); } test().catch(console.error); ``` ## Method 7: Python Test Script Create `test.py`: ```python import requests import json MCP_URL = "http://localhost:3001/mcp" def call_tool(tool_name, arguments): payload = { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": tool_name, "arguments": arguments }, "id": 1 } response = requests.post(MCP_URL, json=payload) return response.json() # Test mark_attendance result = call_tool("mark_attendance", { "studentId": "12345", "date": "2024-01-15", "status": "present" }) print("mark_attendance result:", json.dumps(result, indent=2)) # Test get_repo_info result = call_tool("get_repo_info", { "repoOwner": "sadaf987", "repoName": "test_MCP" }) print("\nget_repo_info result:", json.dumps(result, indent=2)) ``` Run: ```bash python3 test.py ``` ## Method 8: Browser Console (For Testing) Open browser console and run: ```javascript fetch('http://localhost:3001/mcp', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', method: 'tools/list', id: 1 }) }) .then(r => r.json()) .then(console.log); ``` ## Quick Verification Checklist ✅ **Server Running**: `curl http://localhost:3001/mcp/status` ✅ **Tools Listed**: `curl -X POST http://localhost:3001/mcp -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'` ✅ **Tool Works**: Test each tool with curl or test scripts ✅ **GitHub Token**: Ensure `.env` has valid `GITHUB_PERSONAL_ACCESS_TOKEN` ## Recommended Testing Order 1. **Start with server status** - Verify server is running 2. **List tools** - Verify tools are registered 3. **Test mark_attendance** - Simple tool, no external dependencies 4. **Test get_repo_info** - Requires GitHub token but read-only 5. **Test commit_changes** - Requires GitHub token with write permissions ## Troubleshooting If tools don't work: 1. Check server logs for errors 2. Verify GitHub token in `.env` 3. Test with curl first (simplest) 4. Check server console for request logs

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Sadaf987/github_sdk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server