Skip to content

Please set the HttpRequest of HttpClientSseClientTransport default charset encoding to UTF-8. #260

Open
@pcalpha

Description

@pcalpha

When I call the tool which name is Chinese encoding, The mcp client will throws Exception below.

Exception in thread "main" io.modelcontextprotocol.spec.McpError: Tool not found: 天���
at io.modelcontextprotocol.spec.McpClientSession.lambda$sendRequest$11(McpClientSession.java:248)
Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below:

The tool name is messy code.
So please set the HttpRequest of HttpClientSseClientTransport default request encoding to UTF-8.
Please set the encoding of the http request to UTF-8.

sendMessage in HttpClientSseClientTransport.java

String jsonText = this.objectMapper.writeValueAsString(message);
			URI requestUri = Utils.resolveUri(baseUri, endpoint);
			HttpRequest request = this.requestBuilder.uri(requestUri)
				.setHeader("Content-Type", "application/json;charset=UTF-8")
				.POST(HttpRequest.BodyPublishers.ofString(jsonText))
				.build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions