Skip to main content
Glama

New Relic MCP Server

by cloudbring
deployments.test.ts2.16 kB
import { beforeEach, describe, expect, it, vi } from 'vitest'; // Mock REST client used by REST tools const post = vi.fn(); const get = vi.fn(); const del = vi.fn(); vi.mock('../../../src/client/rest-client', () => ({ NewRelicRestClient: vi.fn().mockImplementation(() => ({ post, get, delete: del })), })); import { RestDeploymentsTool } from '../../../src/tools/rest/deployments'; describe('REST Deployments Tool', () => { beforeEach(() => { post.mockReset(); get.mockReset(); del.mockReset(); process.env.NEW_RELIC_API_KEY = 'test-key'; }); it('create: posts payload with revision and optional fields', async () => { post.mockResolvedValue({ status: 200, data: { deployment: {} }, url: 'u' }); const tool = new RestDeploymentsTool(); const res = await tool.create({ application_id: 123, revision: 'abc123', changelog: 'notes', description: 'desc', user: 'me', }); expect(post).toHaveBeenCalledWith('/applications/123/deployments', { deployment: { revision: 'abc123', changelog: 'notes', description: 'desc', user: 'me' }, }); expect((res as any).status).toBe(200); }); it('list: sends page and follows Link next when auto_paginate', async () => { get .mockResolvedValueOnce({ status: 200, data: [{ id: 1 }], links: { next: 'https://api.newrelic.com/v2/applications/1/deployments.json?page=2' }, }) .mockResolvedValueOnce({ status: 200, data: [{ id: 2 }], links: {} }); const tool = new RestDeploymentsTool(); const out = await tool.list({ application_id: 1, auto_paginate: true }); expect(get).toHaveBeenCalledWith('/applications/1/deployments', undefined); expect((out as any).items).toHaveLength(2); }); it('delete: requires confirm and calls delete', async () => { del.mockResolvedValue({ status: 200, data: { ok: true }, url: 'u' }); const tool = new RestDeploymentsTool(); const out = await tool.delete({ application_id: 1, id: 2, confirm: true }); expect(del).toHaveBeenCalledWith('/applications/1/deployments/2'); expect((out as any).status).toBe(200); }); });

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