logoalt Hacker News

Waterluvianyesterday at 10:59 PM3 repliesview on HN

> Instead, I did something a little bit hacky: if the request is for GET /mcp and the Accept header includes text/html and NOT application/json or text/event-stream, I return a HTML page explaining to the user they're trying to view an mcp server and they need to add it to their client.

This feels like less of a hack and more of discovering what some of the HTTP headers are for. You’re choosing rather reasonably how to present the resource found at /mcp when a client is asking for the resource to be presented in HTML format. It’s perfectly fine to offer an HTML response that says “hey this is not really presentable in HTML. Do this instead.”


Replies

singpolyma3today at 1:57 AM

Indeed! Far from a hack it is the entire purpose to the accept header!

RexMtoday at 1:15 AM

I thought the same thing, just discovered content negotiation!