Skip to main content
Glama
server-health-scenario.test.ts2.56 kB
import { describe, expect, it } from '@jest/globals'; import { callTool, callToolsBatchExpect } from './lib/mcp-runner'; const hasTeamCityEnv = Boolean( (process.env['TEAMCITY_URL'] ?? process.env['TEAMCITY_SERVER_URL']) && (process.env['TEAMCITY_TOKEN'] ?? process.env['TEAMCITY_API_TOKEN']) ); describe('Server env and health checks', () => { it('get_server_info and check_teamcity_connection (dev)', async () => { if (!hasTeamCityEnv) return expect(true).toBe(true); const results = await callToolsBatchExpect('dev', [ { tool: 'get_server_info', args: {} }, { tool: 'check_teamcity_connection', args: {} }, ]); const info = results[0]?.result as Record<string, unknown> | undefined; const conn = results[1]?.result as Record<string, unknown> | undefined; expect(info).toBeDefined(); expect(conn).toHaveProperty('ok'); }, 30000); it('check_availability_guard (dev)', async () => { if (!hasTeamCityEnv) return expect(true).toBe(true); const results = await callToolsBatchExpect('dev', [ { tool: 'check_availability_guard', args: {} }, { tool: 'check_availability_guard', args: { failOnWarning: true } }, ]); const guard = results[0]?.result as Record<string, unknown> | undefined; const guardStrict = results[1]?.result as Record<string, unknown> | undefined; expect(guard).toHaveProperty('ok'); expect(guardStrict).toHaveProperty('ok'); }, 30000); it('server metrics and health items (full)', async () => { if (!hasTeamCityEnv) return expect(true).toBe(true); try { const metrics = await callTool<Record<string, unknown>>('full', 'get_server_metrics', {}); expect(metrics).toBeDefined(); } catch (e) { // Not all servers expose metrics; tolerate expect(true).toBe(true); } try { const items = await callTool<Record<string, unknown>>('full', 'list_server_health_items', {}); expect(items).toBeDefined(); const healthItems = (items as Record<string, unknown>)['healthItem'] as | Array<{ href?: string }> | undefined; const firstHref = healthItems?.[0]?.href; if (firstHref) { const locator = firstHref.split('/').pop(); if (locator) { const item = await callTool<Record<string, unknown>>('full', 'get_server_health_item', { locator, }); expect(item).toBeDefined(); } } } catch (e) { // Health items may require permissions; tolerate expect(true).toBe(true); } }, 60000); });

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/Daghis/teamcity-mcp'

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