health_check
Verify WebSim API connectivity to ensure the service is operational and accessible for project browsing, content discovery, and community interactions.
Instructions
Check if the WebSim API is accessible
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- server.js:1086-1114 (handler)The handler function for the 'health_check' tool. It attempts to make a GET request to the WebSim API's projects endpoint to verify connectivity. Returns a JSON response indicating 'healthy' if successful or 'unhealthy' with error details if failed.handler: async (args) => { try { // Try to access a simple endpoint to test connectivity await apiClient.makeRequest('/api/v1/projects', { method: 'GET' }); return { content: [{ type: "text", text: JSON.stringify({ success: true, status: "healthy", message: "WebSim API is accessible", timestamp: new Date().toISOString() }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ success: false, status: "unhealthy", message: `WebSim API is not accessible: ${error.message}`, timestamp: new Date().toISOString() }, null, 2) }] }; } }
- server.js:1079-1115 (registration)The 'health_check' tool registration within the tools array used by the MCP server for listing and calling tools.{ name: "health_check", description: "Check if the WebSim API is accessible", inputSchema: { type: "object", properties: {} }, handler: async (args) => { try { // Try to access a simple endpoint to test connectivity await apiClient.makeRequest('/api/v1/projects', { method: 'GET' }); return { content: [{ type: "text", text: JSON.stringify({ success: true, status: "healthy", message: "WebSim API is accessible", timestamp: new Date().toISOString() }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ success: false, status: "unhealthy", message: `WebSim API is not accessible: ${error.message}`, timestamp: new Date().toISOString() }, null, 2) }] }; } } }
- server.js:1082-1085 (schema)The input schema for the 'health_check' tool, which requires no parameters (empty object).inputSchema: { type: "object", properties: {} },
- server.js:72-101 (helper)The makeRequest method of WebSimAPIClient class, used by the health_check handler to perform the API connectivity test.async makeRequest(endpoint, options = {}) { const url = `${this.baseURL}${endpoint}`; try { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), this.timeout); const response = await fetch(url, { ...options, signal: controller.signal, headers: { 'Content-Type': 'application/json', ...options.headers } }); clearTimeout(timeoutId); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } return await response.json(); } catch (error) { if (error.name === 'AbortError') { throw new Error(`Request timeout after ${this.timeout}ms`); } throw new Error(`API request failed: ${error.message}`); } }