X Tutup
Skip to content

Unable to call tools with Chinese names using HttpClientSseClientTransport and HttpClientStreamableHttpTransport #260

@pcalpha

Description

@pcalpha

Bug description
When I call the tool which name is Chinese, 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.

Environment
Spring AI 1.0.0 , mcp 0.10.0 , without vector store

Java SDK
Openjdk17

Steps to reproduce
Just add a tool with a Chinese name(such as 天气预报), then call the tool.

Recommendation
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();

So just set the default request encoding of HttpRequest in the HttpClientSseClientTransport to UTF-8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurearea/clientbugSomething isn't workinggood first issueGood for newcomersready for workThe goal is clear and work towards it can be commenced

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup