list_expiring_certificates
Identify AWS ACM certificates approaching expiration within a specified timeframe to facilitate timely renewal and prevent service disruptions.
Instructions
Lists ACM certificates expiring within the specified days.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_expiring_certificates"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days threshold (default: 30). |
Implementation Reference
- src/index.ts:1203-1237 (handler)Handler function that executes the tool logic: lists ACM certificates using ListCertificatesCommand, describes each to check expiration date with DescribeCertificateCommand, filters those expiring within 'days' threshold (default 30), and returns a JSON list.
if (name === "list_expiring_certificates") { const days = (args as any)?.days || 30; const thresholdDate = new Date(Date.now() + days * 24 * 60 * 60 * 1000); const listCmd = new ListCertificatesCommand({}); const listResp = await acmClient.send(listCmd); // Note: paginates 1000 by default const expiringCerts = []; // We need to describe to get 'NotAfter' for (const certSummary of listResp.CertificateSummaryList || []) { if (!certSummary.CertificateArn) continue; try { const descCmd = new DescribeCertificateCommand({ CertificateArn: certSummary.CertificateArn }); const descResp = await acmClient.send(descCmd); const cert = descResp.Certificate; if (cert && cert.NotAfter && cert.NotAfter < thresholdDate) { expiringCerts.push({ DomainName: cert.DomainName, CertificateArn: cert.CertificateArn, NotAfter: cert.NotAfter, Status: cert.Status, InUseBy: cert.InUseBy }); } } catch (err) { // Ignore } } return { content: [{ type: "text", text: JSON.stringify(expiringCerts, null, 2) }] }; } - src/index.ts:372-383 (registration)Tool registration in the ListToolsRequestSchema handler, including name, description, and input schema.
name: "list_expiring_certificates", description: "Lists ACM certificates expiring within the specified days.", inputSchema: { type: "object", properties: { days: { type: "number", description: "Number of days threshold (default: 30)." } } } }, - src/index.ts:374-382 (schema)Input schema for the tool parameters.
inputSchema: { type: "object", properties: { days: { type: "number", description: "Number of days threshold (default: 30)." } } } - src/index.ts:62-62 (helper)ACMClient initialization used by the handler.
const acmClient = new ACMClient({}); - src/index.ts:28-28 (helper)Import of ACMClient, ListCertificatesCommand, and DescribeCertificateCommand.
import { ACMClient, ListCertificatesCommand, DescribeCertificateCommand } from "@aws-sdk/client-acm";