Skip to main content
Glama
test-http-api.js2.57 kB
#!/usr/bin/env node // Тест HTTP API AI Ops Hub import axios from 'axios'; const BASE_URL = 'http://localhost:3333'; async function testHealth() { console.log('🧪 Тестирование /health...'); try { const response = await axios.get(`${BASE_URL}/health`); console.log('✅ Health check:', response.data); } catch (error) { console.error('❌ Health check failed:', error.message); } } async function testListTools() { console.log('\n🧪 Тестирование /tools...'); try { const response = await axios.get(`${BASE_URL}/tools`); console.log('✅ Tools list:', response.data); if (response.data.result && response.data.result.tools) { console.log(`📋 Найдено инструментов: ${response.data.result.tools.length}`); response.data.result.tools.forEach((tool, index) => { console.log(` ${index + 1}. ${tool.name}: ${tool.description}`); }); } } catch (error) { console.error('❌ Tools list failed:', error.message); } } async function testCallTool() { console.log('\n🧪 Тестирование /call...'); try { // Тест чтения файла const response = await axios.post(`${BASE_URL}/call`, { name: 'file_read', arguments: { path: 'test-note.md' } }); console.log('✅ File read tool call:', response.data); } catch (error) { console.error('❌ Tool call failed:', error.message); } } async function testStatus() { console.log('\n🧪 Тестирование /status...'); try { const response = await axios.get(`${BASE_URL}/status`); console.log('✅ Status:', response.data); } catch (error) { console.error('❌ Status failed:', error.message); } } async function testNotFound() { console.log('\n🧪 Тестирование 404...'); try { const response = await axios.get(`${BASE_URL}/nonexistent`); console.log('❌ Unexpected success:', response.data); } catch (error) { if (error.response && error.response.status === 404) { console.log('✅ 404 handled correctly:', error.response.data); } else { console.error('❌ Unexpected error:', error.message); } } } async function runHttpTests() { console.log('🚀 Запуск HTTP API тестов...\n'); await testHealth(); await testListTools(); await testCallTool(); await testStatus(); await testNotFound(); console.log('\n✨ HTTP API тесты завершены!'); } runHttpTests().catch(console.error);

Latest Blog Posts

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/Galiusbro/MCP'

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