Skip to main content
Glama

mcp-server-datadog

Apache 2.0
4,489
103
  • Apple
datadog.test.ts3.65 kB
import { describe, it, expect } from 'vitest' import { ApiKeyAuthAuthentication, AppKeyAuthAuthentication, } from '@datadog/datadog-api-client/dist/packages/datadog-api-client-common' import { createDatadogConfig, getDatadogSite } from '../../src/utils/datadog' describe('createDatadogConfig', () => { it('should create a datadog config with custom site when DATADOG_SITE is configured', () => { const datadogConfig = createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: 'test-app-key', site: 'us3.datadoghq.com', }) expect(datadogConfig.authMethods).toEqual({ apiKeyAuth: new ApiKeyAuthAuthentication('test-api-key'), appKeyAuth: new AppKeyAuthAuthentication('test-app-key'), }) expect(datadogConfig.servers[0]?.getConfiguration()?.site).toBe( 'us3.datadoghq.com', ) }) it('should create a datadog config with default site when DATADOG_SITE is not configured', () => { const datadogConfig = createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: 'test-app-key', }) expect(datadogConfig.authMethods).toEqual({ apiKeyAuth: new ApiKeyAuthAuthentication('test-api-key'), appKeyAuth: new AppKeyAuthAuthentication('test-app-key'), }) expect(datadogConfig.servers[0]?.getConfiguration()?.site).toBe( 'datadoghq.com', ) }) }) describe('createDatadogConfig', () => { it('should create a datadog config with custom subdomain when DATADOG_SUBDOMAIN is configured', () => { const datadogConfig = createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: 'test-app-key', subdomain: 'youryour-subdomain', }) expect(datadogConfig.authMethods).toEqual({ apiKeyAuth: new ApiKeyAuthAuthentication('test-api-key'), appKeyAuth: new AppKeyAuthAuthentication('test-app-key'), }) expect(datadogConfig.servers[0]?.getConfiguration()?.subdomain).toBe( 'youryour-subdomain', ) }) it('should create a datadog config with default subdomain when DATADOG_SUBDOMAIN is not configured', () => { const datadogConfig = createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: 'test-app-key', }) expect(datadogConfig.authMethods).toEqual({ apiKeyAuth: new ApiKeyAuthAuthentication('test-api-key'), appKeyAuth: new AppKeyAuthAuthentication('test-app-key'), }) expect(datadogConfig.servers[0]?.getConfiguration()?.subdomain).toBe('api') }) it('should throw an error when DATADOG_API_KEY are not configured', () => { expect(() => createDatadogConfig({ apiKeyAuth: '', appKeyAuth: 'test-app-key', }), ).toThrow('Datadog API key and APP key are required') }) it('should throw an error when DATADOG_APP_KEY are not configured', () => { expect(() => createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: '', }), ).toThrow('Datadog API key and APP key are required') }) }) describe('getDatadogSite', () => { it('should return custom site when DATADOG_SITE is configured', () => { const datadogConfig = createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: 'test-app-key', site: 'us3.datadoghq.com', }) const site = getDatadogSite(datadogConfig) expect(site).toBe('us3.datadoghq.com') }) it('should return default site when DATADOG_SITE is not configured', () => { const datadogConfig = createDatadogConfig({ apiKeyAuth: 'test-api-key', appKeyAuth: 'test-app-key', }) const site = getDatadogSite(datadogConfig) expect(site).toBe('datadoghq.com') }) })

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/winor30/mcp-server-datadog'

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