@path58/p58-n8n 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp/server.bundle.cjs +71 -228
- package/package.json +1 -1
|
@@ -3014,28 +3014,22 @@ function buildPoolOptions() {
|
|
|
3014
3014
|
}
|
|
3015
3015
|
function createPool(cfg) {
|
|
3016
3016
|
const timeoutMs = getEnvNumber("DB_STATEMENT_TIMEOUT_MS", 3e4);
|
|
3017
|
-
const isCatalogOnly = !!(process.env.P58_DATABASE_URL || process.env.MCP_DATABASE_URL) && !process.env.N8N_API_KEY;
|
|
3018
3017
|
const pool = new import_pg.Pool({
|
|
3019
3018
|
host: cfg.host,
|
|
3020
3019
|
port: resolvePoolPort(cfg),
|
|
3021
3020
|
user: cfg.user,
|
|
3022
3021
|
password: cfg.password,
|
|
3023
3022
|
database: cfg.database,
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
// Friends: 0 min — don't hold connections when idle. Full mode: 1.
|
|
3027
|
-
min: getEnvNumber("VALIDATOR_DB_POOL_MIN", isCatalogOnly ? 0 : 1),
|
|
3023
|
+
max: getEnvNumber("VALIDATOR_DB_POOL_MAX", 10),
|
|
3024
|
+
min: getEnvNumber("VALIDATOR_DB_POOL_MIN", 1),
|
|
3028
3025
|
// allowExitOnIdle: true — prevents zombie processes when MCP session ends (RAG-4.35.5)
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
// Friends: 10s connect timeout (fail fast). Full mode: 15s.
|
|
3032
|
-
connectionTimeoutMillis: isCatalogOnly ? 1e4 : 15e3,
|
|
3026
|
+
idleTimeoutMillis: 6e4,
|
|
3027
|
+
connectionTimeoutMillis: 15e3,
|
|
3033
3028
|
statement_timeout: timeoutMs,
|
|
3034
3029
|
options: buildPoolOptions(),
|
|
3035
3030
|
allowExitOnIdle: true,
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
...isCatalogOnly ? {} : { keepAliveInitialDelayMillis: 1e4 }
|
|
3031
|
+
keepAlive: true,
|
|
3032
|
+
keepAliveInitialDelayMillis: 1e4
|
|
3039
3033
|
});
|
|
3040
3034
|
pool.on("error", (err) => {
|
|
3041
3035
|
console.warn(`[pg-pool] Idle connection error (non-fatal): ${err.message}`);
|
|
@@ -3047,24 +3041,6 @@ function getValidatorPool() {
|
|
|
3047
3041
|
validatorPool = createPool(getValidatorDbConfig());
|
|
3048
3042
|
return validatorPool;
|
|
3049
3043
|
}
|
|
3050
|
-
async function warmSingleConnection(pool) {
|
|
3051
|
-
const client = await pool.connect();
|
|
3052
|
-
await client.query("SELECT 1");
|
|
3053
|
-
client.release();
|
|
3054
|
-
}
|
|
3055
|
-
async function warmValidatorPool() {
|
|
3056
|
-
if (poolWarmed)
|
|
3057
|
-
return;
|
|
3058
|
-
const pool = getValidatorPool();
|
|
3059
|
-
const minConns = getEnvNumber("VALIDATOR_DB_POOL_MIN", 1);
|
|
3060
|
-
try {
|
|
3061
|
-
for (let i = 0; i < minConns; i++)
|
|
3062
|
-
await warmSingleConnection(pool);
|
|
3063
|
-
poolWarmed = true;
|
|
3064
|
-
} catch (error) {
|
|
3065
|
-
console.warn("Validator pool warm-up failed, continuing with lazy connection creation:", error);
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
3044
|
async function validatorQuery(sql, params = []) {
|
|
3069
3045
|
const client = await getValidatorPool().connect();
|
|
3070
3046
|
const onClientError = (err) => {
|
|
@@ -3086,7 +3062,7 @@ async function shutdownValidatorPool() {
|
|
|
3086
3062
|
validatorPool = null;
|
|
3087
3063
|
}
|
|
3088
3064
|
}
|
|
3089
|
-
var import_pg, dotenv, path, import_url, import_connection, __filename, __dirname, PROJECT_ROOT, validatorPool
|
|
3065
|
+
var import_pg, dotenv, path, import_url, import_connection, __filename, __dirname, PROJECT_ROOT, validatorPool;
|
|
3090
3066
|
var init_validatorPostgresClient = __esm({
|
|
3091
3067
|
"dist/db/validatorPostgresClient.js"() {
|
|
3092
3068
|
"use strict";
|
|
@@ -3101,7 +3077,6 @@ var init_validatorPostgresClient = __esm({
|
|
|
3101
3077
|
dotenv.config({ path: path.resolve(PROJECT_ROOT, ".env.supabase") });
|
|
3102
3078
|
dotenv.config({ path: path.resolve(PROJECT_ROOT, ".env") });
|
|
3103
3079
|
validatorPool = null;
|
|
3104
|
-
poolWarmed = false;
|
|
3105
3080
|
}
|
|
3106
3081
|
});
|
|
3107
3082
|
|
|
@@ -18461,7 +18436,6 @@ var init_cached_catalog_adapter = __esm({
|
|
|
18461
18436
|
// dist/mcp/server.js
|
|
18462
18437
|
var server_exports = {};
|
|
18463
18438
|
__export(server_exports, {
|
|
18464
|
-
isServerInitialized: () => isServerInitialized,
|
|
18465
18439
|
logStartupSummary: () => logStartupSummary
|
|
18466
18440
|
});
|
|
18467
18441
|
module.exports = __toCommonJS(server_exports);
|
|
@@ -18473,7 +18447,7 @@ var import_types22 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
18473
18447
|
var config = {
|
|
18474
18448
|
// Server identity
|
|
18475
18449
|
SERVER_NAME: "p58-n8n",
|
|
18476
|
-
SERVER_VERSION: "0.2.
|
|
18450
|
+
SERVER_VERSION: "0.2.3",
|
|
18477
18451
|
// Database configuration (from environment)
|
|
18478
18452
|
SUPABASE_URL: process.env.SUPABASE_URL,
|
|
18479
18453
|
SUPABASE_KEY: process.env.SUPABASE_KEY,
|
|
@@ -19205,30 +19179,6 @@ async function injectResponseMetadata(sessionId, toolName, response, executionSt
|
|
|
19205
19179
|
return instrumented;
|
|
19206
19180
|
}
|
|
19207
19181
|
|
|
19208
|
-
// dist/mcp/in-flight-tracker.js
|
|
19209
|
-
var inflightCount = 0;
|
|
19210
|
-
function incrementInflight() {
|
|
19211
|
-
inflightCount++;
|
|
19212
|
-
}
|
|
19213
|
-
function decrementInflight() {
|
|
19214
|
-
if (inflightCount > 0)
|
|
19215
|
-
inflightCount--;
|
|
19216
|
-
}
|
|
19217
|
-
function waitForInflightRequests(timeoutMs) {
|
|
19218
|
-
if (inflightCount === 0)
|
|
19219
|
-
return Promise.resolve();
|
|
19220
|
-
return new Promise((resolve2) => {
|
|
19221
|
-
const deadline = setTimeout(resolve2, timeoutMs);
|
|
19222
|
-
const poll = setInterval(() => {
|
|
19223
|
-
if (inflightCount <= 0) {
|
|
19224
|
-
clearInterval(poll);
|
|
19225
|
-
clearTimeout(deadline);
|
|
19226
|
-
resolve2();
|
|
19227
|
-
}
|
|
19228
|
-
}, 50);
|
|
19229
|
-
});
|
|
19230
|
-
}
|
|
19231
|
-
|
|
19232
19182
|
// dist/validation/l1-structure.js
|
|
19233
19183
|
async function validateL1Structure(workflowJson) {
|
|
19234
19184
|
const startTime = performance.now();
|
|
@@ -30438,13 +30388,7 @@ var AutoFixerRegistry = class _AutoFixerRegistry {
|
|
|
30438
30388
|
}
|
|
30439
30389
|
}
|
|
30440
30390
|
};
|
|
30441
|
-
var
|
|
30442
|
-
function getFixerRegistry() {
|
|
30443
|
-
if (!_fixerRegistry) {
|
|
30444
|
-
_fixerRegistry = new AutoFixerRegistry();
|
|
30445
|
-
}
|
|
30446
|
-
return _fixerRegistry;
|
|
30447
|
-
}
|
|
30391
|
+
var fixerRegistry = new AutoFixerRegistry();
|
|
30448
30392
|
|
|
30449
30393
|
// node_modules/axios/lib/helpers/bind.js
|
|
30450
30394
|
function bind(fn, thisArg) {
|
|
@@ -34942,7 +34886,7 @@ async function runAutofixOnWorkflow(workflowJson, issues) {
|
|
|
34942
34886
|
const { applied: credApplied, changelog: credChangelog } = preAssignCredentials(workflow, issues);
|
|
34943
34887
|
const errorIssues = issues.filter((i) => i.severity === "error");
|
|
34944
34888
|
const problems = errorIssues.map(issueToValidationProblem);
|
|
34945
|
-
const fixResult = await
|
|
34889
|
+
const fixResult = await fixerRegistry.applyFixes(workflow, problems);
|
|
34946
34890
|
const fixChangelog = buildChangelog(fixResult.results);
|
|
34947
34891
|
return {
|
|
34948
34892
|
fixedWorkflow: fixResult.workflow,
|
|
@@ -35337,10 +35281,10 @@ How it works:
|
|
|
35337
35281
|
|
|
35338
35282
|
Validation levels:
|
|
35339
35283
|
- L1: JSON structure, required fields, duplicate node names
|
|
35340
|
-
- L2: Node types exist in catalog (1,
|
|
35341
|
-
- L3: Credential types valid (
|
|
35342
|
-
- L4: Connection patterns exist (
|
|
35343
|
-
- L5: Required parameters configured (
|
|
35284
|
+
- L2: Node types exist in catalog (1,982 nodes)
|
|
35285
|
+
- L3: Credential types valid (654 credentials) \u2014 includes available_credentials lookup
|
|
35286
|
+
- L4: Connection patterns exist (6,900 rules)
|
|
35287
|
+
- L5: Required parameters configured (35,143 params)
|
|
35344
35288
|
- L6: Pattern validation (flow integrity, security, expressions)
|
|
35345
35289
|
|
|
35346
35290
|
Returns detailed issues with severity, location, and suggested fixes.
|
|
@@ -35543,7 +35487,7 @@ var getOperationSchemaToolDefinition = {
|
|
|
35543
35487
|
name: "get_operation_schema",
|
|
35544
35488
|
description: `Get parameter requirements for a specific n8n node operation.
|
|
35545
35489
|
|
|
35546
|
-
Returns the exact required and optional parameters from our
|
|
35490
|
+
Returns the exact required and optional parameters from our 35,143 parameter catalog.
|
|
35547
35491
|
Use this to prevent parameter hallucination when generating n8n workflows.
|
|
35548
35492
|
|
|
35549
35493
|
Examples:
|
|
@@ -36629,77 +36573,6 @@ Examples:
|
|
|
36629
36573
|
}
|
|
36630
36574
|
};
|
|
36631
36575
|
|
|
36632
|
-
// dist/mcp/tools/handlers/shared/n8n-guard.js
|
|
36633
|
-
var SETUP_GUIDE_URL = "https://github.com/tsvika58/p58-n8n/blob/main/docs/AGENT_INSTALL.md";
|
|
36634
|
-
var OFFLINE_TOOLS = /* @__PURE__ */ new Set([
|
|
36635
|
-
"validate_workflow",
|
|
36636
|
-
"get_operation_schema",
|
|
36637
|
-
"check_parameter",
|
|
36638
|
-
"suggest_fix",
|
|
36639
|
-
"list_operations",
|
|
36640
|
-
"list_nodes",
|
|
36641
|
-
"get_node_info",
|
|
36642
|
-
"find_similar_pattern",
|
|
36643
|
-
"get_session_metrics",
|
|
36644
|
-
"get_credential_schema",
|
|
36645
|
-
"setup_check"
|
|
36646
|
-
]);
|
|
36647
|
-
function requiresN8nApiKey(toolName) {
|
|
36648
|
-
return !OFFLINE_TOOLS.has(toolName);
|
|
36649
|
-
}
|
|
36650
|
-
function makeN8nNotConfiguredError() {
|
|
36651
|
-
return {
|
|
36652
|
-
content: [
|
|
36653
|
-
{
|
|
36654
|
-
type: "text",
|
|
36655
|
-
text: JSON.stringify({
|
|
36656
|
-
error: `This tool requires n8n connection. Set N8N_API_URL and N8N_API_KEY in your MCP config. See: ${SETUP_GUIDE_URL}`
|
|
36657
|
-
})
|
|
36658
|
-
}
|
|
36659
|
-
],
|
|
36660
|
-
isError: true
|
|
36661
|
-
};
|
|
36662
|
-
}
|
|
36663
|
-
function isDbConfigError(error) {
|
|
36664
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
36665
|
-
return msg.includes("Missing required validator DB environment variable");
|
|
36666
|
-
}
|
|
36667
|
-
function isDbConnectionError(error) {
|
|
36668
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
36669
|
-
return msg.includes("ECONNREFUSED") || msg.includes("ETIMEDOUT") || msg.includes("connect ETIMEDOUT") || msg.includes("after calling end on the pool") || msg.includes("Connection terminated") || msg.includes("getaddrinfo ENOTFOUND") || msg.includes("too many connections") || msg.includes("remaining connection slots");
|
|
36670
|
-
}
|
|
36671
|
-
function makeDbNotConfiguredResponse() {
|
|
36672
|
-
return {
|
|
36673
|
-
content: [
|
|
36674
|
-
{
|
|
36675
|
-
type: "text",
|
|
36676
|
-
text: JSON.stringify({
|
|
36677
|
-
error: "DB_NOT_CONFIGURED",
|
|
36678
|
-
message: "Catalog features require P58_DATABASE_URL. Set P58_DATABASE_URL in your MCP config to enable this tool.",
|
|
36679
|
-
setup_guide: SETUP_GUIDE_URL
|
|
36680
|
-
})
|
|
36681
|
-
}
|
|
36682
|
-
],
|
|
36683
|
-
isError: true
|
|
36684
|
-
};
|
|
36685
|
-
}
|
|
36686
|
-
function makeDbConnectionErrorResponse() {
|
|
36687
|
-
return {
|
|
36688
|
-
content: [
|
|
36689
|
-
{
|
|
36690
|
-
type: "text",
|
|
36691
|
-
text: JSON.stringify({
|
|
36692
|
-
error: "CATALOG_UNREACHABLE",
|
|
36693
|
-
message: "Catalog database is unreachable. Verify your P58_DATABASE_URL is correct and the database server is accessible. If the problem persists, contact Tsvika.",
|
|
36694
|
-
hint: "Check: (1) connection string starts with postgresql://mcp_friend... (2) port is 6543 (transaction pooler) (3) network allows outbound to AWS eu-north-1",
|
|
36695
|
-
setup_guide: SETUP_GUIDE_URL
|
|
36696
|
-
})
|
|
36697
|
-
}
|
|
36698
|
-
],
|
|
36699
|
-
isError: true
|
|
36700
|
-
};
|
|
36701
|
-
}
|
|
36702
|
-
|
|
36703
36576
|
// dist/mcp/middleware/response-compression.js
|
|
36704
36577
|
function selectFields(item, fields) {
|
|
36705
36578
|
const result = {};
|
|
@@ -36819,11 +36692,8 @@ async function handleListOperations(args) {
|
|
|
36819
36692
|
return toMCPResponse(response);
|
|
36820
36693
|
} catch (error) {
|
|
36821
36694
|
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
36822
|
-
|
|
36823
|
-
|
|
36824
|
-
if (isDbConnectionError(originalError))
|
|
36825
|
-
return makeDbConnectionErrorResponse();
|
|
36826
|
-
return toMCPResponse(createInternalError(correlationId, originalError));
|
|
36695
|
+
const errorResponse = createInternalError(correlationId, originalError);
|
|
36696
|
+
return toMCPResponse(errorResponse);
|
|
36827
36697
|
}
|
|
36828
36698
|
}
|
|
36829
36699
|
var listOperationsToolDefinition = {
|
|
@@ -36920,16 +36790,13 @@ async function handleListNodes(args) {
|
|
|
36920
36790
|
return toMCPResponse(response);
|
|
36921
36791
|
} catch (error) {
|
|
36922
36792
|
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
36923
|
-
|
|
36924
|
-
|
|
36925
|
-
if (isDbConnectionError(originalError))
|
|
36926
|
-
return makeDbConnectionErrorResponse();
|
|
36927
|
-
return toMCPResponse(createInternalError(correlationId, originalError));
|
|
36793
|
+
const errorResponse = createInternalError(correlationId, originalError);
|
|
36794
|
+
return toMCPResponse(errorResponse);
|
|
36928
36795
|
}
|
|
36929
36796
|
}
|
|
36930
36797
|
var listNodesToolDefinition = {
|
|
36931
36798
|
name: "list_nodes",
|
|
36932
|
-
description: `List all available n8n nodes (1,
|
|
36799
|
+
description: `List all available n8n nodes (1,982 total) with filtering and pagination.
|
|
36933
36800
|
|
|
36934
36801
|
Use this to discover available nodes before generating workflows. The tool supports:
|
|
36935
36802
|
- Pagination: Use limit (1-100) and offset for large result sets
|
|
@@ -37086,11 +36953,8 @@ async function handleGetNodeInfo(args) {
|
|
|
37086
36953
|
return toMCPResponse(response);
|
|
37087
36954
|
} catch (error) {
|
|
37088
36955
|
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
37089
|
-
|
|
37090
|
-
|
|
37091
|
-
if (isDbConnectionError(originalError))
|
|
37092
|
-
return makeDbConnectionErrorResponse();
|
|
37093
|
-
return toMCPResponse(createInternalError(correlationId, originalError));
|
|
36956
|
+
const errorResponse = createInternalError(correlationId, originalError);
|
|
36957
|
+
return toMCPResponse(errorResponse);
|
|
37094
36958
|
}
|
|
37095
36959
|
}
|
|
37096
36960
|
var getNodeInfoToolDefinition = {
|
|
@@ -37178,11 +37042,8 @@ async function handleFindSimilarPattern(args) {
|
|
|
37178
37042
|
return toMCPResponse(response);
|
|
37179
37043
|
} catch (error) {
|
|
37180
37044
|
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
37181
|
-
|
|
37182
|
-
|
|
37183
|
-
if (isDbConnectionError(originalError))
|
|
37184
|
-
return makeDbConnectionErrorResponse();
|
|
37185
|
-
return toMCPResponse(createInternalError(correlationId, originalError));
|
|
37045
|
+
const errorResponse = createInternalError(correlationId, originalError);
|
|
37046
|
+
return toMCPResponse(errorResponse);
|
|
37186
37047
|
}
|
|
37187
37048
|
}
|
|
37188
37049
|
var findSimilarPatternToolDefinition = {
|
|
@@ -37379,8 +37240,8 @@ schemas, build_workflow handles validation, autofix, and deployment automaticall
|
|
|
37379
37240
|
|
|
37380
37241
|
Runs L1-L4 validation before creating:
|
|
37381
37242
|
- L1: JSON structure, required fields
|
|
37382
|
-
- L2: Node types exist in catalog (1,
|
|
37383
|
-
- L3: Credential types are valid (
|
|
37243
|
+
- L2: Node types exist in catalog (1,982 nodes)
|
|
37244
|
+
- L3: Credential types are valid (654 credentials)
|
|
37384
37245
|
- L4: Connection patterns exist
|
|
37385
37246
|
|
|
37386
37247
|
Refuses creation if any L1-L4 errors are found.
|
|
@@ -38751,7 +38612,7 @@ async function validateWorkflowObject(workflow, timeoutMs, label) {
|
|
|
38751
38612
|
}
|
|
38752
38613
|
async function runAutoFix(workflow, validationResult, timeoutMs, toolName) {
|
|
38753
38614
|
const problems = validationResult.issues.filter((i) => i.severity === "error").map(issueToValidationProblem2);
|
|
38754
|
-
const fixResult = await withTimeout(
|
|
38615
|
+
const fixResult = await withTimeout(fixerRegistry.applyFixes(workflow, problems), timeoutMs, `${toolName} autofix`);
|
|
38755
38616
|
return { fixedWorkflow: fixResult.workflow, fixResult };
|
|
38756
38617
|
}
|
|
38757
38618
|
async function applyAutoFixIfNeeded(workflow, validationResult, hasErrors, shouldFix, timeoutMs, correlationId, toolName) {
|
|
@@ -39398,7 +39259,7 @@ function issueToValidationProblem3(issue) {
|
|
|
39398
39259
|
}
|
|
39399
39260
|
async function runFixStep(workflow, validation, timeoutMs) {
|
|
39400
39261
|
const problems = validation.issues.filter((i) => i.severity === "error").map(issueToValidationProblem3);
|
|
39401
|
-
const fixResult = await withTimeout(
|
|
39262
|
+
const fixResult = await withTimeout(fixerRegistry.applyFixes(workflow, problems), timeoutMs, "server_autofix:fix");
|
|
39402
39263
|
return {
|
|
39403
39264
|
fixedWorkflow: fixResult.workflow,
|
|
39404
39265
|
fixes: extractAppliedFixes(fixResult)
|
|
@@ -41428,10 +41289,6 @@ and what service it connects to \u2014 don't attempt to build with a broken cred
|
|
|
41428
41289
|
Part of the generation lifecycle: plan_workflow \u2192 test_credential(s) \u2192 build_workflow.
|
|
41429
41290
|
NOT needed for editing or updating existing workflows (use update_workflow or partial_update_workflow).
|
|
41430
41291
|
|
|
41431
|
-
Note: plan_workflow works without n8n (catalog-only mode). To actually deploy
|
|
41432
|
-
workflows with build_workflow, N8N_API_KEY and N8N_API_URL must be configured.
|
|
41433
|
-
Without n8n, use plan_workflow for research and architecture planning only.
|
|
41434
|
-
|
|
41435
41292
|
Response modes:
|
|
41436
41293
|
- "full": All research data within token_budget (default 8,000)
|
|
41437
41294
|
- "summary" (default): Key fields within token_budget (default 4,000)
|
|
@@ -43238,12 +43095,7 @@ async function handleGetCredentialSchema(args) {
|
|
|
43238
43095
|
return buildSchemaResponse(credential_type, rows, nodes, correlationId, startTime);
|
|
43239
43096
|
} catch (error) {
|
|
43240
43097
|
import_logging57.logger.error("get_credential_schema: unexpected error", { correlationId, error });
|
|
43241
|
-
|
|
43242
|
-
if (isDbConfigError(originalError))
|
|
43243
|
-
return makeDbNotConfiguredResponse();
|
|
43244
|
-
if (isDbConnectionError(originalError))
|
|
43245
|
-
return makeDbConnectionErrorResponse();
|
|
43246
|
-
return toMCPResponse(createInternalError(correlationId, originalError));
|
|
43098
|
+
return toMCPResponse(createInternalError(correlationId, error instanceof Error ? error : new Error(String(error))));
|
|
43247
43099
|
}
|
|
43248
43100
|
}
|
|
43249
43101
|
async function handleUnknownType(credentialType, correlationId) {
|
|
@@ -44257,8 +44109,40 @@ When values are collected, marks matching factory.gaps entries as resolved for a
|
|
|
44257
44109
|
}
|
|
44258
44110
|
};
|
|
44259
44111
|
|
|
44112
|
+
// dist/mcp/tools/handlers/shared/n8n-guard.js
|
|
44113
|
+
var SETUP_GUIDE_URL = "https://github.com/tsvika58/n8n-workflow-validator/blob/main/docs/AGENT_INSTALL.md";
|
|
44114
|
+
var OFFLINE_TOOLS = /* @__PURE__ */ new Set([
|
|
44115
|
+
"validate_workflow",
|
|
44116
|
+
"get_operation_schema",
|
|
44117
|
+
"check_parameter",
|
|
44118
|
+
"suggest_fix",
|
|
44119
|
+
"list_operations",
|
|
44120
|
+
"list_nodes",
|
|
44121
|
+
"get_node_info",
|
|
44122
|
+
"find_similar_pattern",
|
|
44123
|
+
"get_session_metrics",
|
|
44124
|
+
"get_credential_schema",
|
|
44125
|
+
"setup_check"
|
|
44126
|
+
]);
|
|
44127
|
+
function requiresN8nApiKey(toolName) {
|
|
44128
|
+
return !OFFLINE_TOOLS.has(toolName);
|
|
44129
|
+
}
|
|
44130
|
+
function makeN8nNotConfiguredError() {
|
|
44131
|
+
return {
|
|
44132
|
+
content: [
|
|
44133
|
+
{
|
|
44134
|
+
type: "text",
|
|
44135
|
+
text: JSON.stringify({
|
|
44136
|
+
error: `This tool requires n8n connection. Set N8N_API_URL and N8N_API_KEY in your MCP config. See: ${SETUP_GUIDE_URL}`
|
|
44137
|
+
})
|
|
44138
|
+
}
|
|
44139
|
+
],
|
|
44140
|
+
isError: true
|
|
44141
|
+
};
|
|
44142
|
+
}
|
|
44143
|
+
|
|
44260
44144
|
// dist/mcp/tools/handlers/setup-check.js
|
|
44261
|
-
var SETUP_GUIDE_URL2 = "https://github.com/tsvika58/
|
|
44145
|
+
var SETUP_GUIDE_URL2 = "https://github.com/tsvika58/n8n-workflow-validator/blob/main/docs/AGENT_INSTALL.md";
|
|
44262
44146
|
var N8N_PROBE_TIMEOUT_MS = 2e3;
|
|
44263
44147
|
var N8N_PROBE_PORTS = [5678, 5679];
|
|
44264
44148
|
async function probeN8nUrl(url2) {
|
|
@@ -44448,18 +44332,13 @@ async function dispatchToolCall(name, args) {
|
|
|
44448
44332
|
if (requiresN8nApiKey(name) && !process.env.N8N_API_KEY) {
|
|
44449
44333
|
return makeN8nNotConfiguredError();
|
|
44450
44334
|
}
|
|
44451
|
-
|
|
44452
|
-
|
|
44453
|
-
if (
|
|
44454
|
-
|
|
44455
|
-
|
|
44456
|
-
return createValidationErrorResponse(validation.error);
|
|
44457
|
-
return await tool.handler(validation.data);
|
|
44458
|
-
}
|
|
44459
|
-
return await tool.handler(args);
|
|
44460
|
-
} finally {
|
|
44461
|
-
decrementInflight();
|
|
44335
|
+
if (tool.inputSchema && hasSchema(name)) {
|
|
44336
|
+
const validation = validateToolInput(name, args);
|
|
44337
|
+
if (!validation.success)
|
|
44338
|
+
return createValidationErrorResponse(validation.error);
|
|
44339
|
+
return tool.handler(validation.data);
|
|
44462
44340
|
}
|
|
44341
|
+
return tool.handler(args);
|
|
44463
44342
|
}
|
|
44464
44343
|
async function handleToolCall(name, args, sessionId = "default") {
|
|
44465
44344
|
const startTime = Date.now();
|
|
@@ -44477,9 +44356,7 @@ function registerAllTools() {
|
|
|
44477
44356
|
registerTool({ ...entry, inputSchema: toolSchemas[entry.name] });
|
|
44478
44357
|
}
|
|
44479
44358
|
}
|
|
44480
|
-
|
|
44481
|
-
// dist/mcp/server.js
|
|
44482
|
-
init_validatorPostgresClient();
|
|
44359
|
+
registerAllTools();
|
|
44483
44360
|
|
|
44484
44361
|
// dist/mcp/middleware/credential-redaction.js
|
|
44485
44362
|
var MAX_DEPTH = 20;
|
|
@@ -44652,7 +44529,6 @@ var defaultDeps = {
|
|
|
44652
44529
|
};
|
|
44653
44530
|
async function runCleanup(serverName, deps) {
|
|
44654
44531
|
try {
|
|
44655
|
-
await waitForInflightRequests(5e3);
|
|
44656
44532
|
await deps.shutdownPool();
|
|
44657
44533
|
deps.clearCache();
|
|
44658
44534
|
deps.clearConfigCache?.();
|
|
@@ -44684,24 +44560,7 @@ function registerShutdownHandlers(serverName, deps) {
|
|
|
44684
44560
|
}
|
|
44685
44561
|
|
|
44686
44562
|
// dist/mcp/server.js
|
|
44687
|
-
var SETUP_GUIDE_URL3 = "https://github.com/tsvika58/
|
|
44688
|
-
var _serverInitialized = false;
|
|
44689
|
-
function isServerInitialized() {
|
|
44690
|
-
return _serverInitialized;
|
|
44691
|
-
}
|
|
44692
|
-
function buildInitializingResponse() {
|
|
44693
|
-
return {
|
|
44694
|
-
content: [{
|
|
44695
|
-
type: "text",
|
|
44696
|
-
text: JSON.stringify({
|
|
44697
|
-
error: "SERVER_INITIALIZING",
|
|
44698
|
-
message: "Server is still loading. Please retry in a moment.",
|
|
44699
|
-
retryAfterMs: 2e3
|
|
44700
|
-
})
|
|
44701
|
-
}],
|
|
44702
|
-
isError: true
|
|
44703
|
-
};
|
|
44704
|
-
}
|
|
44563
|
+
var SETUP_GUIDE_URL3 = "https://github.com/tsvika58/n8n-workflow-validator/blob/main/docs/AGENT_INSTALL.md";
|
|
44705
44564
|
function logStartupSummary(n8nConnected) {
|
|
44706
44565
|
const apiKey = process.env.N8N_API_KEY;
|
|
44707
44566
|
const n8nUrl = process.env.N8N_API_URL ?? process.env.N8N_API_BASE_URL ?? "http://localhost:5678/api/v1";
|
|
@@ -44746,9 +44605,6 @@ function toCallToolResult(response) {
|
|
|
44746
44605
|
server.setRequestHandler(import_types22.CallToolRequestSchema, async (request) => {
|
|
44747
44606
|
const { name, arguments: args } = request.params;
|
|
44748
44607
|
try {
|
|
44749
|
-
if (!_serverInitialized) {
|
|
44750
|
-
return toCallToolResult(buildInitializingResponse());
|
|
44751
|
-
}
|
|
44752
44608
|
const response = await handleToolCall(name, args ?? {});
|
|
44753
44609
|
return toCallToolResult(redactMCPResponse(response));
|
|
44754
44610
|
} catch (error) {
|
|
@@ -44758,25 +44614,13 @@ server.setRequestHandler(import_types22.CallToolRequestSchema, async (request) =
|
|
|
44758
44614
|
});
|
|
44759
44615
|
async function main() {
|
|
44760
44616
|
const transport = new import_stdio.StdioServerTransport();
|
|
44761
|
-
const startMs = Date.now();
|
|
44762
44617
|
await server.connect(transport);
|
|
44763
|
-
console.error(`[INIT] MCP handshake complete in ${Date.now() - startMs}ms`);
|
|
44764
|
-
registerAllTools();
|
|
44765
|
-
_serverInitialized = true;
|
|
44766
44618
|
const toolCount = getRegisteredTools().length;
|
|
44767
|
-
console.error(
|
|
44619
|
+
console.error(`${config.SERVER_NAME} v${config.SERVER_VERSION} running on stdio (${toolCount} tools registered)`);
|
|
44768
44620
|
logStartupSummary(Boolean(process.env.N8N_API_KEY));
|
|
44769
44621
|
registerShutdownHandlers(config.SERVER_NAME);
|
|
44770
44622
|
void warmCredentialCache().catch(() => {
|
|
44771
44623
|
});
|
|
44772
|
-
if (process.env.P58_DATABASE_URL || process.env.MCP_DATABASE_URL) {
|
|
44773
|
-
void warmValidatorPool().then(() => {
|
|
44774
|
-
console.error("catalog: connected \u2713");
|
|
44775
|
-
}).catch((err) => {
|
|
44776
|
-
console.error(`catalog: WARNING \u2014 connection failed: ${err.message}`);
|
|
44777
|
-
console.error("catalog: tools will retry on first use, but check P58_DATABASE_URL if errors persist");
|
|
44778
|
-
});
|
|
44779
|
-
}
|
|
44780
44624
|
}
|
|
44781
44625
|
main().catch((error) => {
|
|
44782
44626
|
console.error("Server failed to start:", error);
|
|
@@ -44784,7 +44628,6 @@ main().catch((error) => {
|
|
|
44784
44628
|
});
|
|
44785
44629
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44786
44630
|
0 && (module.exports = {
|
|
44787
|
-
isServerInitialized,
|
|
44788
44631
|
logStartupSummary
|
|
44789
44632
|
});
|
|
44790
44633
|
/*! Bundled license information:
|