Skip to main content
Glama

New Relic MCP Server

by cloudbring
validate-credentials.test.ts1.3 kB
import type { Mock } from 'vitest'; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { NewRelicClient } from '../../../src/client/newrelic-client'; const originalFetch = global.fetch; beforeAll(() => { // @ts-expect-error override in tests global.fetch = vi.fn(); }); afterEach(() => { vi.clearAllMocks(); }); afterAll(() => { global.fetch = originalFetch; }); describe('NewRelicClient.validateCredentials', () => { let client: NewRelicClient; beforeEach(() => { vi.clearAllMocks(); process.env.NEW_RELIC_API_KEY = 'test-api-key'; process.env.NEW_RELIC_ACCOUNT_ID = '123456'; client = new NewRelicClient(); }); it('returns true for valid credentials', async () => { (global.fetch as unknown as Mock).mockResolvedValueOnce({ ok: true, json: async () => ({ data: { actor: { user: { id: 'user-123', email: 'test@example.com' } } }, }), }); const result = await client.validateCredentials(); expect(result).toBe(true); }); it('returns false for invalid credentials', async () => { (global.fetch as unknown as Mock).mockResolvedValueOnce({ ok: false, status: 401 }); const result = await client.validateCredentials(); expect(result).toBe(false); }); });

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/cloudbring/newrelic-mcp'

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