get_network_elements
Retrieve network device inventory and details for a specific customer to manage hardware assets and monitor network infrastructure.
Instructions
Get network elements inventory for a specific customer. Returns network devices and their details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | Yes | The customer ID |
Implementation Reference
- src/index.ts:267-281 (handler)The handler function for the 'get_network_elements' tool. It extracts the customerId from arguments, validates it, calls the API endpoint '/inventory/network-elements' using makeApiCall, and returns the JSON response as text content.case "get_network_elements": { const customerId = args?.customerId as string; if (!customerId) { throw new Error("customerId is required"); } const data = await makeApiCall("/inventory/network-elements", customerId); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/index.ts:108-120 (schema)The tool definition including name, description, and input schema for 'get_network_elements'. Specifies that customerId is a required string input.{ name: "get_network_elements", description: "Get network elements inventory for a specific customer. Returns network devices and their details.", inputSchema: { type: "object", properties: { customerId: { type: "string", description: "The customer ID", }, }, required: ["customerId"], },
- src/index.ts:223-228 (registration)Registration of all tools via the ListToolsRequestSchema handler, which returns the tools array containing 'get_network_elements'.server.setRequestHandler(ListToolsRequestSchema, async () => { logger.debug('ListTools request received'); return { tools, }; });
- src/index.ts:34-70 (helper)Shared helper function makeApiCall used by the get_network_elements handler to make authenticated GET requests to the Cisco CX Cloud API.async function makeApiCall(endpoint: string, customerId?: string): Promise<any> { const token = await authClient.getAccessToken(); let url = `${CX_CLOUD_BASE_URL}${endpoint}`; if (customerId) { url += `${endpoint.includes('?') ? '&' : '?'}customerId=${customerId}`; } logger.debug(`Making API call to: ${url}`); try { logger.apiRequest('GET', url, { Authorization: 'Bearer ***', }); const startTime = Date.now(); const response = await axios.get(url, { headers: { Authorization: `Bearer ${token}`, }, }); const duration = Date.now() - startTime; logger.apiResponse('GET', url, response.status, response.data); logger.debug(`API call completed in ${duration}ms`); return response.data; } catch (error) { logger.apiError('GET', url, error); if (axios.isAxiosError(error)) { throw new Error( `API call failed: ${error.response?.status} - ${error.response?.data?.message || error.message}` ); } throw error; } }