Skip to content

test(mcp-server): add MCP protocol E2E tests (Phase 1) #1498

Description

@JeremyDev87

Parent

E2E test infrastructure initiative.

Problem

The MCP server (apps/mcp-server/) is the core product but has zero E2E tests. Unit tests cover 84 files at 80% coverage, but no test verifies the actual MCP protocol handshake, tool invocation, or transport layer (stdio/SSE) end-to-end.

A broken stdio transport or malformed JSON-RPC response would only be caught in production.

Scope

New directory: apps/mcp-server/tests/e2e/

stdio transport tests (~8 tests)

  • MCP handshake: initializeinitialized response with capabilities
  • Tool listing: tools/list returns all registered tools
  • Tool invocation: search_rules with query → valid result
  • Tool invocation: get_agent_details with agent name → valid result
  • Tool invocation: activate with prompt → rules + specialists
  • Resource listing: resources/list returns rules:// resources
  • Resource read: resources/read with valid URI → content
  • Error handling: invalid JSON-RPC request → proper error response

SSE transport tests (~5 tests)

  • SSE endpoint accepts connection and sends events
  • Tool call via HTTP POST → SSE event with result
  • Bearer token auth: valid token → 200, missing token → 401
  • Multiple concurrent SSE connections
  • Graceful disconnection

Error edge cases (~3 tests)

  • Non-existent tool name → JSON-RPC error
  • Malformed tool arguments → meaningful error
  • Large payload handling (oversized query)

Technical approach

  • Framework: Vitest (matches existing setup)
  • stdio: child_process.spawn the compiled server, write JSON-RPC to stdin, read stdout
  • SSE: Start NestJS TestingModule with HTTP listener, connect via fetch + EventSource
  • Config: Separate vitest.config.e2e.ts with extended timeout (30s)
  • CI: Add e2e-mcp job to .github/workflows/dev.yml (runs after build)

Test commands

yarn workspace codingbuddy test:e2e        # Run MCP E2E tests
yarn workspace codingbuddy test:e2e:stdio   # stdio transport only
yarn workspace codingbuddy test:e2e:sse     # SSE transport only

Acceptance criteria

  • apps/mcp-server/tests/e2e/ directory with ≥15 tests
  • stdio transport: handshake + tool call + resource read + error
  • SSE transport: connection + tool call + auth + disconnect
  • vitest.config.e2e.ts with 30s timeout
  • test:e2e script in package.json
  • CI job passes on PR
  • No mocking of MCP transport — real stdin/stdout or real HTTP

Out of scope

  • Performance/load testing
  • Prompt content validation (covered by unit tests)
  • Plugin ↔ MCP integration (Phase 3)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions