Files
n8n-mcp/tests/integration/mcp-protocol
czlonkowski 059723ff75 fix: resolve 99 integration test failures through comprehensive fixes
- Fixed MCP transport initialization (unblocked 111 tests)
- Fixed database isolation and FTS5 search syntax (9 tests)
- Fixed MSW mock server setup and handlers (6 tests)
- Fixed MCP error handling response structures (16 tests)
- Fixed performance test thresholds for CI environment (15 tests)
- Fixed session management timeouts and cleanup (5 tests)
- Fixed database connection management (3 tests)

Improvements:
- Added NODE_DB_PATH support for in-memory test databases
- Added test mode logger suppression
- Enhanced template sanitizer for security
- Implemented environment-aware performance thresholds

Results: 229/246 tests passing (93.5% success rate)
Remaining: 16 tests need additional work (protocol compliance, timeouts)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 08:15:22 +02:00
..

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

  1. The InMemoryTransport from MCP SDK has some limitations with connection lifecycle
  2. Tests use the actual database, so they require data/nodes.db to exist
  3. Some tests are currently skipped due to transport issues (being worked on)

Future Improvements

  1. Mock the database for true unit testing
  2. Add WebSocket transport tests
  3. Add authentication/authorization tests
  4. Add rate limiting tests
  5. Add more performance benchmarks