|
23 | 23 | import com.fasterxml.jackson.databind.ObjectMapper; |
24 | 24 |
|
25 | 25 | import io.modelcontextprotocol.client.transport.ResponseSubscribers.ResponseEvent; |
| 26 | +import io.modelcontextprotocol.spec.HttpHeaders; |
26 | 27 | import io.modelcontextprotocol.spec.McpClientTransport; |
27 | 28 | import io.modelcontextprotocol.spec.McpSchema; |
28 | 29 | import io.modelcontextprotocol.spec.ProtocolVersions; |
@@ -66,8 +67,6 @@ public class HttpClientSseClientTransport implements McpClientTransport { |
66 | 67 |
|
67 | 68 | private static final String MCP_PROTOCOL_VERSION = ProtocolVersions.MCP_2024_11_05; |
68 | 69 |
|
69 | | - private static final String MCP_PROTOCOL_VERSION_HEADER_NAME = "MCP-Protocol-Version"; |
70 | | - |
71 | 70 | private static final Logger logger = LoggerFactory.getLogger(HttpClientSseClientTransport.class); |
72 | 71 |
|
73 | 72 | /** SSE event type for JSON-RPC messages */ |
@@ -403,7 +402,7 @@ public Mono<Void> connect(Function<Mono<JSONRPCMessage>, Mono<JSONRPCMessage>> h |
403 | 402 | .uri(uri) |
404 | 403 | .header("Accept", "text/event-stream") |
405 | 404 | .header("Cache-Control", "no-cache") |
406 | | - .header(MCP_PROTOCOL_VERSION_HEADER_NAME, MCP_PROTOCOL_VERSION) |
| 405 | + .header(HttpHeaders.PROTOCOL_VERSION, MCP_PROTOCOL_VERSION) |
407 | 406 | .GET(); |
408 | 407 | return Mono.from(this.httpRequestCustomizer.customize(builder, "GET", uri, null)); |
409 | 408 | }).flatMap(requestBuilder -> Mono.create(sink -> { |
@@ -529,7 +528,7 @@ private Mono<HttpResponse<String>> sendHttpPost(final String endpoint, final Str |
529 | 528 | return Mono.defer(() -> { |
530 | 529 | var builder = this.requestBuilder.copy() |
531 | 530 | .uri(requestUri) |
532 | | - .header(MCP_PROTOCOL_VERSION_HEADER_NAME, MCP_PROTOCOL_VERSION) |
| 531 | + .header(HttpHeaders.PROTOCOL_VERSION, MCP_PROTOCOL_VERSION) |
533 | 532 | .POST(HttpRequest.BodyPublishers.ofString(body)); |
534 | 533 | return Mono.from(this.httpRequestCustomizer.customize(builder, "POST", requestUri, body)); |
535 | 534 | }).flatMap(customizedBuilder -> { |
|
0 commit comments