get_faults
Retrieve active faults from Cisco C-Series servers with details like severity, description, cause, and timestamps. Filter results by severity level to identify specific issues.
Instructions
List all active faults with severity, description, cause, and timestamps. Optionally filter by severity level.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| severity | No | Filter faults by severity level |
Implementation Reference
- src/tools/faults.ts:16-58 (handler)The getFaults async function is the handler that executes the tool logic. It fetches fault instances via resolveClass('faultInst'), optionally filters by severity, sorts by severity order (critical first) then by creation time descending, and returns a JSON string with total count and fault details.
export async function getFaults(input: { severity?: string }): Promise<string> { let faults = await resolveClass("faultInst"); if (input.severity) { faults = faults.filter((f) => f.severity === input.severity); } // Sort: critical first, then by creation time descending const severityOrder: Record<string, number> = { critical: 0, major: 1, minor: 2, warning: 3, info: 4, cleared: 5, }; faults.sort((a, b) => { const sa = severityOrder[a.severity] ?? 99; const sb = severityOrder[b.severity] ?? 99; if (sa !== sb) return sa - sb; return (b.created || "").localeCompare(a.created || ""); }); return JSON.stringify( { total: faults.length, faults: faults.map((f) => ({ severity: f.severity, code: f.code, description: f.descr, cause: f.cause, dn: f.dn, type: f.type, created: f.created, lastTransition: f.lastTransition, acknowledged: f.ack, })), }, null, 2, ); } - src/tools/faults.ts:4-14 (schema)The getFaultsDef object defines the tool's metadata: name ('get_faults'), description, and inputSchema using Zod. The schema accepts an optional 'severity' parameter that must be one of: critical, major, minor, warning, info, or cleared.
export const getFaultsDef = { name: "get_faults", description: "List all active faults with severity, description, cause, and timestamps. Optionally filter by severity level.", inputSchema: z.object({ severity: z .enum(["critical", "major", "minor", "warning", "info", "cleared"]) .optional() .describe("Filter faults by severity level"), }), }; - src/index.ts:88-93 (registration)Registration of the get_faults tool with the MCP server using server.tool(). It passes the name, description, inputSchema.shape from getFaultsDef, and wraps the getFaults handler with error handling via wrapHandler().
server.tool( getFaultsDef.name, getFaultsDef.description, getFaultsDef.inputSchema.shape, wrapHandler(getFaults), );