get-metric-metadata
Retrieve detailed metadata for Datadog metrics to understand their meaning, type, unit, and proper usage.
Instructions
Retrieve detailed metadata about a specific metric, including its type, description, unit, and other attributes. Use this to understand a metric's meaning and proper usage.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metricName | Yes |
Implementation Reference
- src/tools/getMetricMetadata.ts:27-46 (handler)The execute function implementing the core logic of the 'get-metric-metadata' tool by querying Datadog's Metrics API for the specified metric's metadata.execute: async (params: GetMetricMetadataParams) => { try { const { metricName } = params; const apiInstance = new v1.MetricsApi(configuration); const apiParams: v1.MetricsApiGetMetricMetadataRequest = { metricName: metricName }; const response = await apiInstance.getMetricMetadata(apiParams); return response; } catch (error) { console.error( `Error fetching metadata for metric ${params.metricName}:`, error ); throw error; } }
- src/index.ts:162-174 (registration)Registers the 'get-metric-metadata' tool with the MCP server, including description, input schema validation, and delegation to the handler.server.tool( "get-metric-metadata", "Retrieve detailed metadata about a specific metric, including its type, description, unit, and other attributes. Use this to understand a metric's meaning and proper usage.", { metricName: z.string() }, async (args) => { const result = await getMetricMetadata.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );
- src/index.ts:166-167 (schema)Zod input schema defining the required 'metricName' parameter as a string.metricName: z.string() },
- src/tools/getMetricMetadata.ts:10-25 (helper)Initialization helper that configures the Datadog API client with authentication and site settings.initialize: () => { const configOpts = { authMethods: { apiKeyAuth: process.env.DD_API_KEY, appKeyAuth: process.env.DD_APP_KEY } }; configuration = client.createConfiguration(configOpts); if (process.env.DD_METRICS_SITE) { configuration.setServerVariables({ site: process.env.DD_METRICS_SITE }); } },
- src/tools/getMetricMetadata.ts:3-5 (schema)TypeScript type for the input parameters used in the handler.type GetMetricMetadataParams = { metricName: string; };