Skip to content

How does MCP server obtain the parameters after the SSE endpoint URL for authentication #2779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fanslin opened this issue Apr 17, 2025 · 1 comment
Labels

Comments

@fanslin
Copy link

fanslin commented Apr 17, 2025

For example, my mcp client configuration is as follows:
{
"mcpServers": {
"xxx": {
"url": "https://www.xx.com/sse?ak=apikey"
}
}
}
I want to obtain the ak parameter for verification in the mcp server implemented by springAI. How should I do it?

@renpengben
Copy link

I also encountered this problem. The endpoint configuration should be opened. Similar to configuring baseuri.
The problem is the automated configuration HttpClientSseClientTransport when using the default endpoint
@bean
public List mcpHttpClientTransports(McpSseClientProperties sseProperties,
ObjectProvider objectMapperProvider) {

	ObjectMapper objectMapper = objectMapperProvider.getIfAvailable(ObjectMapper::new);

	List<NamedClientMcpTransport> sseTransports = new ArrayList<>();

	for (Map.Entry<String, SseParameters> serverParameters : sseProperties.getConnections().entrySet()) {

		var transport = new HttpClientSseClientTransport(HttpClient.newBuilder(), serverParameters.getValue().url(),
				objectMapper);
		sseTransports.add(new NamedClientMcpTransport(serverParameters.getKey(), transport));
	}

	return sseTransports;
}


@Deprecated(forRemoval = true)
public HttpClientSseClientTransport(HttpClient.Builder clientBuilder, String baseUri, ObjectMapper objectMapper) {
	this(clientBuilder, baseUri, DEFAULT_SSE_ENDPOINT, objectMapper);
}

@Deprecated(forRemoval = true)
public HttpClientSseClientTransport(HttpClient.Builder clientBuilder, String baseUri, String sseEndpoint,
		ObjectMapper objectMapper) {
	this(clientBuilder, HttpRequest.newBuilder(), baseUri, sseEndpoint, objectMapper);
}

The endpoint property configuration should be added to McpSseClientProperties.

mcp:
  client:
    sse:
      connections:
        server1:
          url: https://mcp.amap.com
          sse-endpoint: /sse?key=xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants