UNPKG

n8n-mcp

Version:

Integration between n8n workflow automation and Model Context Protocol (MCP)

76 lines 3.66 kB
#!/usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const n8n_api_client_1 = require("../services/n8n-api-client"); const dotenv_1 = require("dotenv"); const axios_1 = __importDefault(require("axios")); (0, dotenv_1.config)(); async function testLimitedResults() { const apiUrl = process.env.N8N_API_URL || 'https://n8n.energyhouse.com.pl'; const apiKey = process.env.N8N_API_KEY || 'n8n_api_f94c0b3fb3bf1a3a690f37bb0c5c0de43c7b690c0a33c88b6baaa37ae896dc96'; console.log('Testing for limited results issue...'); console.log('API URL:', apiUrl); console.log('API Key:', apiKey.substring(0, 20) + '...\n'); try { console.log('=== Test 1: Direct API call with X-N8N-API-KEY ==='); const directResponse = await axios_1.default.get(`${apiUrl}/api/v1/workflows`, { headers: { 'X-N8N-API-KEY': apiKey, 'Content-Type': 'application/json' }, params: { limit: 100 } }); console.log(`Direct API: Found ${directResponse.data.data.length} workflows`); console.log('\n=== Test 2: Using N8nApiClient ==='); const client = new n8n_api_client_1.N8nApiClient({ baseUrl: apiUrl, apiKey: apiKey }); const clientResponse = await client.listWorkflows({ limit: 100 }); console.log(`N8nApiClient: Found ${clientResponse.data.length} workflows`); console.log('\n=== Comparison ==='); console.log(`Direct API returned: ${directResponse.data.data.length} workflows`); console.log(`N8nApiClient returned: ${clientResponse.data.length} workflows`); if (directResponse.data.data.length !== clientResponse.data.length) { console.error('WARNING: Result mismatch detected!'); console.log('\nFirst workflow from direct API:'); console.log(JSON.stringify(directResponse.data.data[0], null, 2)); console.log('\nFirst workflow from N8nApiClient:'); console.log(JSON.stringify(clientResponse.data[0], null, 2)); } else { console.log('✅ Both methods returned the same number of workflows'); } console.log('\n=== Test 3: Credentials ==='); const credentialsResponse = await client.listCredentials({ limit: 100 }); console.log(`Found ${credentialsResponse.data.length} credentials`); console.log('\n=== Test 4: Pagination Test ==='); let allWorkflows = []; let cursor = undefined; let page = 0; do { const pageResponse = await client.listWorkflows({ limit: 10, cursor: cursor }); allWorkflows = allWorkflows.concat(pageResponse.data); cursor = pageResponse.nextCursor || undefined; page++; console.log(`Page ${page}: ${pageResponse.data.length} workflows, nextCursor: ${cursor ? 'yes' : 'no'}`); } while (cursor && page < 10); console.log(`Total workflows via pagination: ${allWorkflows.length}`); } catch (error) { console.error('Error:', error.message); if (error.response) { console.error('Response status:', error.response.status); console.error('Response data:', error.response.data); console.error('Response headers:', error.response.headers); } } } testLimitedResults().catch(console.error); //# sourceMappingURL=test-limited-results.js.map