io.modelcontextprotocol.util.Utils#resolveUri incorrectly handles nested paths
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 冷清
- 技術堆疊
- java
- 領域
- api, networking
研究方向
從 io.modelcontextprotocol.util.Utils#resolveUri 開始,檢查巢狀路徑的基底 URL 和端點 URL 是如何解析的。使用不以 /sse 結尾的 SSE 伺服器 URL 執行提供的 SSEClientTest 重現;當用戶端能夠成功連線且不再出現報告的重新導向相關錯誤時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:
Bug description
It took me four hours to locate and fix this Bug,
When I create a simple link, it always reminds me of http status 302. Finally, it was located that the SSE MCP Server of the business side was redirected.
Environment
Please provide as many details as possible: Spring MCP version, Java version, which vector store you use if any, etc
Java SDK
Steps to reproduce
It's very simple. When you have an SSE MCP SERVER but the interface does not end with /sse, an error will definitely be reported when creating the connection.
Expected behavior
Adapt to the SSE MCP SERVER with non-standard users
I first fork and change the IO. Modelcontextprotocol. Util. Utils# resolveUri logic is as follows
old code
public static URI resolveUri(URI baseUrl, String endpointUrl) {
URI endpointUri = URI.create(endpointUrl);
if (endpointUri.isAbsolute() && !isUnderBaseUri(baseUrl, endpointUri)) {
throw new IllegalArgumentException("Absolute endpoint URL does not match the base URL.");
}
else {
return baseUrl.resolve(endpointUri);
}
}
new code
public static URI resolveUri(URI baseUrl, String endpointUrl) {
if (endpointUrl.equals(DEFAULT_SSE_ENDPOINT)) {
return baseUrl;
}
else {
URI endpointUri = URI.create(endpointUrl);
return baseUrl.resolve(endpointUri);
}
}
Minimal Complete Reproducible example
You only need to replace the following URL with a URL that does not end with SSE, and it can be reproduced
import io.modelcontextprotocol.client.McpClient;
import io.modelcontextprotocol.client.McpSyncClient;
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
import io.modelcontextprotocol.spec.McpSchema;
import org.junit.Test;
import java.time.Duration;
public class SSEClientTest {
private String youUrl = "https://host:port/aaa/bbb/cccc";
@Test
public void testSSE() {
mockSSEClient(youUrl);
}
/**
* Test MCP Client
*/
private void mockSSEClient(String url) {
McpSyncClient client = McpClient.sync(create(url))
.requestTimeout(Duration.ofSeconds(3))
.initializationTimeout(Duration.ofSeconds(1))
.capabilities(McpSchema.ClientCapabilities.builder().build())
.build();
client.initialize();
for (McpSchema.Tool tool : client.listTools().tools()) {
System.out.println(" Tool :" + tool);
}
}
private HttpClientSseClientTransport create(String url) {
return HttpClientSseClientTransport.builder(url).build();
}
}
- 主要語言
- Java
- 星號
- 3.7k
- 分支
- 1.1k
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 9
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/java-sdk 的其他 Issue
-
area/transport bug P2
難度 2/5 1-3 小時 新手友好度 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
難度 2/5 1-3 小時 新手友好度 84/100
modelcontextprotocol/java-sdk#1124 · 1 則留言 ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities 未關閉bug P2 ready for work
難度 2/5 1-3 小時 新手友好度 68/100
modelcontextprotocol/java-sdk#1086 · 1 則留言 ·
-
enhancement good first issue P3
難度 2/5 1-3 小時 新手友好度 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
難度 2/5 1-3 小時 新手友好度 74/100
modelcontextprotocol/java-sdk#898 · 1 則留言 ·
查看 modelcontextprotocol/java-sdk 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 76/100
-
bug needs triage
難度 2/5 1-3 小時 新手友好度 76/100
-
難度 1/5 1 小時以內 新手友好度 94/100
objectionary/hone-maven-plugin#1061 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
spring-projects/spring-modulith#1895 ·