Skip to content

The response is garbled characters #236

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
a09090443 opened this issue May 2, 2025 · 8 comments
Open

The response is garbled characters #236

a09090443 opened this issue May 2, 2025 · 8 comments

Comments

@a09090443
Copy link

I create a example, and response was a Chinese content, but I find the response in log file is correct, below image

Image

when I use Claude desktop, I got wrong respose

Image

this is my code

Image

I don't know what's the problem.

note: I try to use spring ai mcp, the reponse was correct content like below

Image

@mkouba
Copy link
Contributor

mkouba commented May 2, 2025

We'll need a simple reproducer app + your environment info (OS, Java, locale, etc.). It's very likely some encoding issue...

@a09090443
Copy link
Author

a09090443 commented May 2, 2025

My environment information:
OS: windows 11
JAVA: OpenJdk 21
Project examples: url
Claude configuration:
{ "mcpServers": { "example": { "command": "java", "args": [ "-jar", "D:\\MCP\\spring-0.0.1-SNAPSHOT.jar" ] } } }

thanks.

@mkouba
Copy link
Contributor

mkouba commented May 5, 2025

I've tried to copy your tool method in a demo app and call the tool from the Dev UI and it seems to work fine.

@a09090443 have you tried to use the -Dfile.encoding=UTF-8 system property?

@maxandersen does it ring a bell? It looks like an encoding issue...

@a09090443
Copy link
Author

@mkouba Thanks for your reply.
I tried before and got same error.

Image

Image

and I wrote unit test and used MCP Inspector

the unit test was right, but MCP Inspector had same issue.

Image

Image

the spring use MCP Inspector test was right.

Image

Not only Claude desktop, same problem happend in other software like Cherrys studio.

@mkouba
Copy link
Contributor

mkouba commented May 5, 2025

I tested your tool with the MCP Inspector and OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS) on my Linux box and I see no problem.

So I guess that it could be related to the OS - Windows. Unfortunately, I don't have a Windows box to make more tests 🤷.

@a09090443
Copy link
Author

Ok, I'll use Linux test again.

@maxandersen
Copy link
Member

Very weird - never seen it.

If you can share as much as possible I'll try reproduce on my windows box.

As Martin says it's most likely an encoding issue so something different in the OS / Claude desktop or java call used when running it.

Just need to spot what.

@a09090443
Copy link
Author

Guys, I found the issue because of Windows settings,
I change Windows encoding to utf8, the mcp server response right content.
Windows has to enable (BETA: Use Unicode UTF-8 for worldwide language support checkbox)

Image

But I don't understand why Spring works fine.

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

No branches or pull requests

3 participants