feat: add n8n_evaluations tool for reading evaluation test runs#935
Conversation
Three read methods for n8n's evaluation Public API (n8n >= 2.30): listTestRuns, getTestRun, listTestCases, with types transcribed from the sanitized public DTOs. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
handleListTestRuns / handleGetTestRun / handleListTestCases. 403 maps to API-key scope guidance (keys created before n8n 2.30 lack testRun scopes); 404 disambiguates pre-2.30 instances from wrong ids via the cached instance version. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Consolidated action tool: list_runs / get_run / list_cases, wired into dispatch, per-operation gating (TOOL_OPERATION_PARAM), and tool docs. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new consolidated, read-only MCP tool (n8n_evaluations) to read n8n Public API evaluation test-run data (runs, run details, and per-case results), including API client support, handler-level validation/error mapping, and documentation updates across tool registries and docs.
Changes:
- Introduces
N8nApiClientmethods and TypeScript types for evaluation test-run endpoints (list_runs,get_run,list_cases). - Adds new MCP handlers with input validation and disambiguated 403/404 error guidance (scopes vs. pre-2.30 vs. wrong IDs).
- Registers and documents the new tool across tool definitions, docs index, README, skills-pack copy, and changelog.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/services/n8n-api-client.test.ts | Adds API-client tests for evaluation endpoints (params, hostile IDs, legacy envelopes, error wrapping). |
| tests/unit/mcp/handlers-evaluations.test.ts | Adds handler tests for success paths, validation, pagination notes, and 403/404 mappings. |
| src/types/n8n-api.ts | Adds types for test run summaries, test cases, params, and list responses. |
| src/services/n8n-api-client.ts | Implements listTestRuns, getTestRun, and listTestCases in the API client. |
| src/mcp/tools-n8n-manager.ts | Registers the new n8n_evaluations tool and enables per-action gating via TOOL_OPERATION_PARAM. |
| src/mcp/tools-documentation.ts | Adds n8n_evaluations to the quick tool list. |
| src/mcp/tool-docs/workflow_management/n8n-evaluations.ts | New detailed tool documentation (actions, prerequisites, examples, pitfalls). |
| src/mcp/tool-docs/workflow_management/index.ts | Exports the new evaluations tool doc. |
| src/mcp/tool-docs/index.ts | Registers n8n_evaluations in the documentation map. |
| src/mcp/server.ts | Adds server-side validation/dispatch wiring for n8n_evaluations. |
| src/mcp/handlers-n8n-manager.ts | Adds Zod schemas, handler implementations, and error-mapping for evaluation test runs. |
| README.md | Documents n8n_evaluations in the tools list. |
| package.json | Bumps package version to 2.65.0. |
| package-lock.json | Updates lockfile for the release. |
| data/skills/n8n-mcp-tools-expert/SKILL.md | Updates skills-pack tool list to include n8n_evaluations. |
| CHANGELOG.md | Adds a 2.65.0 entry describing the new evaluations tool and behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case 'n8n_evaluations': | ||
| // Requires action parameter, runId validation done in dispatch based on action | ||
| validationResult = args.action | ||
| ? { valid: true, errors: [] } | ||
| : { valid: false, errors: [{ field: 'action', message: 'action is required' }] }; | ||
| break; |
There was a problem hiding this comment.
Fixed in cd4e881 — the first-layer validation case now reports a missing workflowId alongside action.
| const response = await client.listTestRuns(input.workflowId, { | ||
| status: input.status as TestRunStatus | undefined, | ||
| limit: input.limit || 100, | ||
| cursor: input.cursor, | ||
| }); | ||
|
|
||
| return { | ||
| success: true, | ||
| data: { | ||
| testRuns: response.data, | ||
| returned: response.data.length, | ||
| nextCursor: response.nextCursor, | ||
| hasMore: !!response.nextCursor, | ||
| ...(response.data.length === 0 ? { | ||
| _note: 'No test runs. Runs exist only for workflows with an evaluation trigger that have been executed at least once.' | ||
| } : {}), | ||
| ...(response.nextCursor ? { | ||
| _note: 'More test runs available. Use cursor to get next page.' | ||
| } : {}) | ||
| } | ||
| }; |
There was a problem hiding this comment.
Fixed in cd4e881 — replaced the two conditional spreads with a single computed note (empty-list hint takes precedence, and it's now filter-aware when a status filter matches nothing).
Test Results Summary📊 ArtifactsGenerated at Thu, 16 Jul 2026 11:02:50 GMT |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
npm install in the feature worktree added peer entries (playwright, browserbase, watsonx and friends) unrelated to this change. Restore the lockfile from main and re-apply only the version bump. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Consolidate the three duplicated catch blocks into handleTestRunError (follows the file's handleCrudError idiom); single computed _note - Fetch the instance version on 404 when the cache is cold, so a pre-2.30 instance gets version guidance on a session's first call - Filter-aware empty-list note (status filter no longer implies evaluations are unconfigured); 403 hint also names licensing and workflow access as causes - Validate workflowId at the first validation layer (Copilot) - Tests: empty-string coercion, cursor passthrough, filter-aware note, cold-cache version fetch incl. fetch failure, 403 on get_run Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| return { | ||
| success: false, | ||
| error: 'Workflow or test run not found. A runId must belong to the given workflowId; check both ids.', | ||
| code: error.code, | ||
| }; |
The previous restore (899c467) used the local main ref, which predated the n8n 2.30.x dependency update - npm ci failed with missing @smithy/* entries. origin/main's lockfile is what CI validated on #933; re-apply only the 2.65.0 version fields on top of it. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Live testing against a pre-2.30 instance showed the test-runs path is swallowed by the 2.29-era workflow-versions route, whose spec rejects unknown query params - so the forced limit=100 produced 'Unknown query parameter' instead of the 404 our error mapping explains. n8n's server default is the same 100; send limit only when the caller sets one. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Live end-to-end verification against n8n 2.30.6 (self-hosted, SQLite):
Observation for the record: on this SQLite instance the API returns |
n8n-mcp v2.65.0 (PR czlonkowski/n8n-mcp#935) adds a read-only tool for n8n 2.30's evaluation Public API. Skill updates: - tools-expert SKILL.md: added to the requires-API tool inventory - tools-expert WORKFLOW_GUIDE.md: full section (list_runs/get_run/ list_cases usage, key-scope 403 gotcha, three-way 404, pagination guidance, executionId drill-down into n8n_executions) + Additional Tools entry - using-n8n-mcp-skills router: Test & run bullet with the read-only and key re-creation caveats All guidance mirrors live-verified behavior against n8n 2.30.6. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirrors czlonkowski/n8n-skills@05eea48 so the shipped data/skills copy matches the source: WORKFLOW_GUIDE.md section for n8n_evaluations and the router's Test & run bullet. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
What
New consolidated read-only tool
n8n_evaluationsexposing the evaluation test-run endpoints n8n shipped in its Public API in 2.30.0 (n8n-io/n8n#33455):list_runsGET /workflows/{id}/test-runsstatusfilterget_runGET /workflows/{id}/test-runs/{runId}list_casesGET /workflows/{id}/test-runs/{runId}/test-casesexecutionId(default limit 20 — cases can be large)Why
Evaluation results are the observability signal for AI workflows: poll runs, export results to external dashboards, compare metric aggregates across prompt/model versions, catch regressions. Each case links to its execution via
executionId, composing withn8n_executionsfor drill-down.Error mapping
The feature has three confusable failure modes; the handlers disambiguate:
testRunscopes. Keys created before n8n 2.30 silently don't have them and must be re-created (also covers unlicensed evaluations).runIdthat belongs to a different workflow.Scope notes
run/cancelactions in this same tool when n8n ships them — no schema break.TOOL_OPERATION_PARAM, soDISABLED_TOOL_OPERATIONS=n8n_evaluations:...per-action gating works.data/skills/n8n-mcp-tools-expert/SKILL.md) updated in-repo; the upstream n8n-skills source repo needs the matching one-line edit before its next sync.Testing
Conceived by Romuald Członkowski - www.aiadvisors.pl/en
🤖 Generated with Claude Code