mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 21:43:07 +00:00
**Critical Fix**: Tests now properly test the MCP handler layer (the actual product) instead of raw API client. **Changes**: - All 15 tests now use `handleCreateWorkflow()` MCP handler - Tests validate `McpToolResponse` structure (`success`, `data`, `error`) - Created `mcp-context.ts` helper for configuring InstanceContext - Fixed ERROR_HANDLING_WORKFLOW to add main connection (MCP validation requirement) - Updated error/edge case tests to expect validation failures (correct MCP behavior) **MCP Handler Validation**: - Error scenarios now correctly expect `success: false` with validation errors - Edge cases updated to reflect MCP handler's proper pre-validation - Documents that MCP validation is CORRECT behavior (catches errors early) **Test Results**: All 15 scenarios passing - 8 valid workflow tests → expect `success: true` - 7 validation tests (errors/edge cases) → expect `success: false` **Why This Matters**: AI assistants interact with MCP handlers, not raw API client. Testing the wrong layer would miss MCP-specific logic and validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
15 lines
444 B
TypeScript
15 lines
444 B
TypeScript
import { InstanceContext } from '../../../../src/types/instance-context';
|
|
import { getN8nCredentials } from './credentials';
|
|
|
|
/**
|
|
* Creates MCP context for testing MCP handlers against real n8n instance
|
|
* This is what gets passed to MCP handlers (handleCreateWorkflow, etc.)
|
|
*/
|
|
export function createMcpContext(): InstanceContext {
|
|
const creds = getN8nCredentials();
|
|
return {
|
|
n8nApiUrl: creds.url,
|
|
n8nApiKey: creds.apiKey
|
|
};
|
|
}
|