| Filename | Latest commit message | Latest commit date |
|---|---|---|
* /sse still not working * Add transport type selector to inspector UI and comprehensive transport testing - Add transport type dropdown to inspector UI (auto, HTTP, SSE) with session storage persistence - Update test framework to support transport type selection in test scenarios - Add comprehensive test cases covering: * Working /mcp endpoints with auto and HTTP transports * SSE endpoint with SSE transport (expected to pass) * SSE endpoint with auto transport (expected to fail - demonstrates current fallback issue) - Test structure now provides clear visibility into transport-specific behavior - All tests properly named and categorized for easy identification of failing scenarios * Gearing up to "make amp do it" * fix: improve SSE fallback logic in auto transport mode - Fix issue where SSE fallback was not attempted when HTTP transport failed - Specific error types (404, 405, CORS) now correctly trigger SSE fallback - Allow SSE fallback even when component state is 'failed' from previous attempts - Maintain proper error handling for non-fallback HTTP errors - All 6 transport scenarios now pass integration tests The core issue was that failConnection() was being called for HTTP errors before returning 'fallback', which set the component state to 'failed' and prevented the orchestration logic from attempting SSE fallback. Now only specific HTTP errors that should trigger fallback avoid calling failConnection immediately, allowing the SSE transport to be attempted as expected. --------- Co-authored-by: Glen Maddern <glen@glenmaddern.com> |
||
| .. | ||
| integration | ||
| setup | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| tsconfig.json | ||
| vitest.config.ts | ||
Integration Test Suite
This directory contains integration tests for the use-mcp project that test the complete flow:
- Building the use-mcp library
- Building the inspector example
- Starting MCP server(s)
- Testing browser connections to MCP servers
Setup
Install test dependencies:
cd test
pnpm install
Running Tests
Run all integration tests (shows browser window):
cd test
pnpm test
Run tests headlessly (no browser window):
cd test
pnpm test:headless
Run tests in watch mode (re-runs on file changes):
cd test
pnpm test:watch
Run tests with interactive UI:
cd test
pnpm test:ui
Debug hanging processes:
cd test
pnpm test:debug
Test Architecture
-
Global Setup (
setup/global-setup.ts):- Builds use-mcp library and inspector
- Starts hono-mcp server on port 9901
- Starts static file server for inspector dist files
-
Global Teardown (
setup/global-teardown.ts):- Stops all servers and cleans up resources
-
Integration Tests (
integration/mcp-connection.test.ts):- Uses Playwright to automate browser interactions
- Tests connection to MCP servers defined in
MCP_SERVERSarray - Verifies successful connections and tool availability
- Logs debug information on failures
Adding New MCP Servers
To test additional MCP servers, add them to the MCP_SERVERS array in the test file:
const MCP_SERVERS = [
{
name: 'hono-mcp',
url: 'http://localhost:9901/mcp',
expectedTools: 1,
},
{
name: 'new-server',
url: 'http://localhost:9902/mcp',
expectedTools: 2,
},
]
Make sure to also update the global setup to start the new server process.
Test Output
Successful connections will log:
- ✅ Connection success message
- 📋 List of available tools with count
Failed connections will log:
- ❌ Failure message
- 🐛 Debug log from the inspector interface
Troubleshooting
If tests fail:
- Check that all required dependencies are installed
- Verify that ports 9901 and 8000+ are available
- Look at the debug log output for MCP connection errors
- Check browser console logs for JavaScript errors
- Run tests with
--headedflag to see browser interactions