Creating a human readable MCP error page. #5767
Unanswered
nielsbasjes
asked this question in
Q&A
Replies: 1 comment
-
|
I propose this fix for this: #5769 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
FYI: I'm currently trying out a local build of the 2.0.0-SNAPSHOT code base.
I wrote my first McpTool to learn how this all works.
One of the things I noticed is that when a user opens the /mcp path I usually get an HTTP 405 without any explanation.
In an attempt to show a human readable error message I simply added a GetMapping linked to the content type HTML like this:
I would expect that this would be shown when a normal browser opens this url, but it doesn't. I still get the 405 error.
After digging through the code I found that in the Spring AI code a
RouterFunctionis used that simply returns the 405 on all GET operations on the/mcp.So to override that I wrote this (code summary only):
My main question is if this is really the way to do this?
Or is there a simpler and cleaner way I'm simply not aware of yet?
Also: Why such a hard coded error?
I also noticed that those RouterFunction calls all do a very broad GET/POST/DELETE and then in the handler check for the actually accepted content type. I think this is a better alternative:
Beta Was this translation helpful? Give feedback.
All reactions