ping
Test authentication and connection to the Headlesshost API to verify system accessibility and operational status.
Instructions
Test authentication and connection to the Headlesshost API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:171-202 (registration)Registration of the "ping" MCP tool, including schema (empty input), title, description, and inline handler that proxies to the Headlesshost API /tools/ping endpoint, returning JSON response or error.server.registerTool( "ping", { title: "Ping API", description: "Test authentication and connection to the Headlesshost API", inputSchema: {}, }, async () => { try { const response: AxiosResponse<ApiResponse> = await apiClient.get("/tools/ping"); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } } );
- src/index.ts:178-201 (handler)Handler function for "ping" tool: sends GET request to API /tools/ping, formats response as text content block, handles errors using handleApiError and marks as error.async () => { try { const response: AxiosResponse<ApiResponse> = await apiClient.get("/tools/ping"); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } }
- src/index.ts:173-176 (schema)Schema definition for "ping" tool: title, description, and empty inputSchema (no parameters required).{ title: "Ping API", description: "Test authentication and connection to the Headlesshost API", inputSchema: {},
- src/index.ts:158-166 (helper)Helper function handleApiError used by the "ping" handler (and others) to format API error responses.function handleApiError(error: any): string { if (error.response) { return `API Error ${error.response.status}: ${error.response.data?.message || error.response.statusText}`; } else if (error.request) { return "Network Error: Unable to reach API server"; } else { return `Error: ${error.message}`; } }