Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[HELP NEEDED] io.modelcontextprotocol.spec.McpError: Client failed to initialize by explicit API call

Đang mở
#501 8 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
api, backend, networking

Hướng nghiên cứu

Tái hiện lỗi với client.initialize().block() bằng HTTPS, sau đó kiểm tra HttpClientStreamableHttpTransport.java quanh dòng 512 và ResponseSubscribers.java quanh dòng 287. So sánh phản hồi khởi tạo HTTPS với đường dẫn SSE đang hoạt động và hành vi VS Code được báo cáo. Được xem là hoàn tất khi quá trình khởi tạo HTTPS của Java hoàn tất thành công mà không có McpError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

question

Hi everyone,

I'm working on a chat-based plugin using the MCP Java SDK (io.modelcontextprotocol.sdk:mcp:0.11.0) and getting the error io.modelcontextprotocol.spec.McpError: Client failed to initialize by explicit API call when using HTTPS transport.

Problem: Client initialization fails with the above error when using HTTPS transport. The same server works perfectly with VS Code (which also uses HTTPS) and with SSE transport from our Java client.

Context:

  • The MCP server is an internal implementation that works perfectly with VS Code via HTTPS
  • SSE transport connects successfully with the same server from our Java client
  • Only HTTPS transport is failing during the initialization phase in Java SDK
  • Server definitely supports MCP-over-HTTP since VS Code connects successfully

Code snippet:

if ("http".equalsIgnoreCase(transportType)) { // Note: actually using HTTPS URL
HttpClientStreamableHttpTransport.Builder builder = HttpClientStreamableHttpTransport.builder(mcpUrl)
.customizeRequest(requestBuilder -> {
System.out.println("Customizing request for HTTP MCP client: " + mcpUrl);
// Add authentication headers, if available
if (authHeader != null && !authHeader.isEmpty()) {
authHeader.forEach((key, value) -> {
requestBuilder.setHeader(key, value);
});
}
})
.endpoint(URI.create(mcpUrl).getRawPath());

client = McpClient.async(builder.build()).requestTimeout(Duration.ofSeconds(60)).build();

}

client.initialize().block();

Underlying Stack Trace:

java.lang.RuntimeException: Failed to send message: DummyEvent[responseInfo=jdk.internal.net.http.ResponseInfoImpl@fbe869d]
	at io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport.lambda$sendMessage$27(HttpClientStreamableHttpTransport.java:512)
	...
	at io.modelcontextprotocol.client.transport.ResponseSubscribers$BodilessResponseLineSubscriber.hookOnComplete(ResponseSubscribers.java:287)
 
 
Key observations:
1. Error occurs during client initialization with `client.initialize().block()`
2. Involves `BodilessResponseLineSubscriber.hookOnComplete` suggesting HTTP response processing issue
3. Same server works with VS Code via HTTPS - so server implementation should be correct
4. Same server works with SSE transport from Java - so authentication/connectivity is fine
 
Questions:
1. Has anyone encountered this specific `McpError` with HTTP transport initialization?
2. Are there differences in how the Java SDK's HTTP transport vs VS Code's HTTP client handle MCP initialization?
3. Could this be related to HTTP headers, request methods, or connection handling specific to the Java SDK?
4. Are there additional configuration options for `HttpClientStreamableHttpTransport` that might resolve this?
 
What works vs what doesn't:
- ✅ VS Code → Server via HTTPS  
- ✅ Java Client → Server via SSE
- ❌ Java Client → Server via HTTPS (fails with initialization error)
 
This suggests the issue is specifically with how the Java SDK's HTTP transport handles initialization compared to VS Code's implementation.
 
Any insights on resolving this initialization error with HTTP transport would be greatly appreciated!
Ngôn ngữ chính
Java
Star
3.7k
Fork
1.1k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
9

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/java-sdk

Tất cả issue của modelcontextprotocol/java-sdk

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.