Package com.tnsai.mcp.client
Class TransportDetector
java.lang.Object
com.tnsai.mcp.client.TransportDetector
Auto-detects the best MCP transport for a given endpoint.
Detection order:
- Streamable HTTP - POST a JSON-RPC request, check for valid response
- SSE - GET with Accept: text/event-stream
- HTTP fallback - basic HttpTransport
Usage
McpTransport transport = TransportDetector.detect("https://api.example.com/mcp");
McpClient client = new McpClient(transport);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic McpTransportDetects the best transport for a given endpoint.static McpTransportDetects the best transport for a given endpoint with custom headers.
-
Method Details
-
detect
Detects the best transport for a given endpoint.- Parameters:
endpoint- the MCP server endpoint URL- Returns:
- the detected transport
- Throws:
IOException- if detection fails for all transport types
-
detect
Detects the best transport for a given endpoint with custom headers.- Parameters:
endpoint- the MCP server endpoint URLheaders- custom headers for authentication- Returns:
- the detected transport
- Throws:
IOException- if detection fails for all transport types
-