Skip to content

fix: Allow overriding the MCP endpoint for non-supported MediaTypes#5769

Open
nielsbasjes wants to merge 1 commit intospring-projects:mainfrom
nielsbasjes:McpEndpoint
Open

fix: Allow overriding the MCP endpoint for non-supported MediaTypes#5769
nielsbasjes wants to merge 1 commit intospring-projects:mainfrom
nielsbasjes:McpEndpoint

Conversation

@nielsbasjes
Copy link
Copy Markdown

The Routing to the mcp endpoint was hardcoded to route everything to the provided methods.
In the code of those methods then was checked if the right content-type could be provided for what the client could accept.

The effect is that implementing an HTML page to a user who accidentally opened the mcp endpoint was much harder than needed.

This change moves the accepted content type checks to the routing function and removes the needless GET handlers where GET is not implemented.

The advantage of this change is that now you can simply provide a meaningful explanation by simply implementing something like @GetMapping(value = "/mcp", produces = MediaType.TEXT_HTML_VALUE)

The downside of this change is that now doing a GET that is not allowed returns a 404 (Not Found) instead of the current 405 (Method Not Allowed).

I'm looking forward to your feedback on this proposal.

…like HTML).

Signed-off-by: Niels Basjes <niels@basjes.nl>
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

Successfully merging this pull request may close these issues.

1 participant