mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 05:23:08 +00:00
feat: add version info to health check and fix healthz endpoint
- Fixed health check to use correct /healthz endpoint instead of /health - Added MCP version (mcpVersion) and supported n8n version (supportedN8nVersion) to health check response - Added versionNote field with instructions for AI agents about manual version verification - n8n API limitation: instance version cannot be determined automatically - Updated axios usage for healthz endpoint access with proper error handling
This commit is contained in:
@@ -87,17 +87,32 @@ export class N8nApiClient {
|
||||
// Health check to verify API connectivity
|
||||
async healthCheck(): Promise<HealthCheckResponse> {
|
||||
try {
|
||||
// First try the health endpoint
|
||||
const response = await this.client.get('/health');
|
||||
return response.data;
|
||||
// Try the standard healthz endpoint (available on all n8n instances)
|
||||
const baseUrl = this.client.defaults.baseURL || '';
|
||||
const healthzUrl = baseUrl.replace(/\/api\/v\d+\/?$/, '') + '/healthz';
|
||||
|
||||
const response = await axios.get(healthzUrl, {
|
||||
timeout: 5000,
|
||||
validateStatus: (status) => status < 500
|
||||
});
|
||||
|
||||
if (response.status === 200 && response.data?.status === 'ok') {
|
||||
return {
|
||||
status: 'ok',
|
||||
features: {} // Features detection would require additional endpoints
|
||||
};
|
||||
}
|
||||
|
||||
// If healthz doesn't work, fall back to API check
|
||||
throw new Error('healthz endpoint not available');
|
||||
} catch (error) {
|
||||
// If health endpoint doesn't exist, try listing workflows with limit 1
|
||||
// If healthz endpoint doesn't exist, try listing workflows with limit 1
|
||||
// This is a fallback for older n8n versions
|
||||
try {
|
||||
await this.client.get('/workflows', { params: { limit: 1 } });
|
||||
return {
|
||||
status: 'ok',
|
||||
features: {} // We can't determine features without proper health endpoint
|
||||
features: {}
|
||||
};
|
||||
} catch (fallbackError) {
|
||||
throw handleN8nApiError(fallbackError);
|
||||
|
||||
Reference in New Issue
Block a user