io.modelcontextprotocol.util.Utils#resolveUri incorrectly handles nested paths
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- java
- Domínio
- api, networking
Direção de pesquisa
Comece em io.modelcontextprotocol.util.Utils#resolveUri e inspecione como a URL base e a URL do endpoint são resolvidas para caminhos aninhados. Execute a reprodução fornecida de SSEClientTest com uma URL de servidor SSE que não termine em /sse; considera-se concluído quando o cliente se conectar com sucesso sem o erro relacionado ao redirecionamento relatado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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();
}
}
- Linguagem predominante
- Java
- Estrelas
- 3.7k
- Forks
- 1.1k
- Merge médio
- 1d 15h
- PRs com merge (30d)
- 9
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/java-sdk
-
area/transport bug P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
modelcontextprotocol/java-sdk#1124 · 1 comentário ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Abertabug P2 ready for work
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
modelcontextprotocol/java-sdk#1086 · 1 comentário ·
-
enhancement good first issue P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
modelcontextprotocol/java-sdk#898 · 1 comentário ·
Todas as issues de modelcontextprotocol/java-sdk
Issues semelhantes
-
Bug Java Platform: Java
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
getsentry/sentry-java#6138 · 1 comentário ·
-
bug needs triage p2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 comentário ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
apache/rocketmq-dashboard#4654 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100