Skip to content

Conversation

@davenpi
Copy link
Collaborator

@davenpi davenpi commented Jul 29, 2025

What changed?

Added tests for server transport components and updated interfaces

Why?

Implemented in a prior PR without tests. Tests showed some interface issues.

Impact

More trust in our server version the transport.

Testing

Test first PR

Review notes

N/A

Checklist

  • All new and old tests pass
  • Code follows our style guidelines
  • Documentation updated if needed
  • Breaking changes documented in commit messages

davenpi added 9 commits July 28, 2025 11:55
What changed and why:
- Replace silent message dropping with proper exception raising
- Add client ID validation before attempting message send
- Raise ValueError for non-existent clients per ServerTransport
  contract
- Raise ConnectionError when client exists but has no active streams
- Add comprehensive test suite covering all send scenarios

Impact:
- Developers get clear feedback when message delivery fails
- Follows ServerTransport interface contract for exception handling
- Better debugging experience with explicit error conditions
- Maintains backward compatibility for successful send operations
What changed and why:
- Add test coverage for client_messages(), disconnect_client(), and
  close()
- Focus on orchestration behavior rather than implementation details
- Use simple mocking for manager dependencies to keep tests fast
- Cover edge cases like non-existent clients and idempotent operations

Impact:
- Complete test coverage for ServerTransport interface methods
- Clear documentation of expected behavior through tests
- Foundation for testing more complex HTTP handler logic next
- Maintains fast test execution with focused unit tests
What changed and why:
- Add integration-style tests for _handle_get_request covering all
  branches
- Test happy path: valid request creates server stream with SSE
  response
- Test error cases: invalid headers (400), missing session (400),
  invalid session (404), stream creation failure (500)
- Use real session manager with mocked stream manager for balanced
  approach
- Verify actual HTTP status codes and response bodies per MCP spec

Impact:
- Complete branch coverage for GET request handler
- Validates proper MCP Streamable HTTP specification compliance
- Tests actual client contract (HTTP request → HTTP response)
- Foundation for testing remaining HTTP handlers (POST, DELETE)
- High confidence in GET endpoint behavior for all client scenarios
What changed and why:
- Add TestPostRequestProcessing class covering headers, JSON parsing,
  and message routing
- Add TestSessionValidation class for complex session validation logic
- Test all POST handler branches: validation errors, message types,
  session handling
- Improve error messages with specific details (missing vs invalid
  headers, expected values)
- Add defensive error handling to _create_request_stream method
- Use integration-style testing with real session manager for better
  coverage
- Fix GET handler tests for new error messages

Impact:
- Complete branch coverage for POST request handler
- Better developer experience with actionable error messages
- Robust error handling prevents unhandled exceptions in stream
  creation
- Clear separation of concerns between request processing and session
  validation
- High confidence in POST endpoint behavior for all client scenarios
What changed and why:
- Add tests for StreamManager
- Clean up StreamManager interface
- Fixed tests that were broken by the StreamManager interface changes

Impact:
- StreamManager is now a more robust and testable component
@davenpi davenpi changed the title Test/streamable http Server streamable http tests Jul 29, 2025
@davenpi davenpi merged commit bb56108 into main Jul 29, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants