mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 05:23:08 +00:00
Two critical fixes for integration test failures: **1. Foreign Key Constraint Violations** Root cause: Tests inserted into template_node_configs without corresponding entries in templates table, causing FK constraint failures. Fixes: - template-node-configs.test.ts: Pre-create 1000 test templates in beforeEach() - template-examples-e2e.test.ts: Create templates in seedTemplateConfigs() and adjust test cases to use non-conflicting template IDs **2. Removed Tool References** Root cause: Tests referenced get_node_for_task tool removed in v2.15.0. Fixes: - tool-invocation.test.ts: Removed entire get_node_for_task test suite - session-management.test.ts: Replaced get_node_for_task test with search_nodes Test results: ✅ template-node-configs.test.ts: 20/20 passed ✅ template-examples-e2e.test.ts: 13/13 passed ✅ tool-invocation.test.ts: 28/28 passed ✅ session-management.test.ts: 16 passed, 2 skipped All integration tests now comply with foreign key constraints and use only existing MCP tools as of v2.15.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
MCP Protocol Integration Tests
This directory contains comprehensive integration tests for the Model Context Protocol (MCP) implementation in n8n-mcp.
Test Structure
Core Tests
- basic-connection.test.ts - Tests basic MCP server functionality and tool execution
- protocol-compliance.test.ts - Tests JSON-RPC 2.0 compliance and protocol specifications
- tool-invocation.test.ts - Tests all MCP tool categories and their invocation
- session-management.test.ts - Tests session lifecycle, multiple sessions, and recovery
- error-handling.test.ts - Tests error handling, edge cases, and invalid inputs
- performance.test.ts - Performance benchmarks and stress tests
Helper Files
- test-helpers.ts - TestableN8NMCPServer wrapper for testing with custom transports
Running Tests
# Run all MCP protocol tests
npm test -- tests/integration/mcp-protocol/
# Run specific test file
npm test -- tests/integration/mcp-protocol/basic-connection.test.ts
# Run with coverage
npm test -- tests/integration/mcp-protocol/ --coverage
Test Coverage
These tests ensure:
- ✅ JSON-RPC 2.0 protocol compliance
- ✅ Proper request/response handling
- ✅ All tool categories are tested
- ✅ Error handling and edge cases
- ✅ Session management and lifecycle
- ✅ Performance and scalability
Known Issues
- The InMemoryTransport from MCP SDK has some limitations with connection lifecycle
- Tests use the actual database, so they require
data/nodes.dbto exist - Some tests are currently skipped due to transport issues (being worked on)
Future Improvements
- Mock the database for true unit testing
- Add WebSocket transport tests
- Add authentication/authorization tests
- Add rate limiting tests
- Add more performance benchmarks