Hi folks, Question re: mcp servers. I’m trying ...
# server
t
Hi folks, Question re: mcp servers. I’m trying to set up a StreamableHttpServer transport on ktor. I’ve noticed that the kotlin mcp sdk has a PR open for this here. The comments in the PR mention it’s not possible to use this with ktor due to limitations in the routing dsl. I checked out the code from the PR and tried to get it working using the suggestion in the description but to no avail. Does anyone know of a workaround for this? Assuming I have the transport from the PR is there a way to get it working with ktor?
d
No idea about ktor I'm afraid - but if you're looking to deploy to a remote server then you're going to need Steamable HTTP . I'm surprised that the Kotlin SDK doesn't support it yet. Does Koog have anything? But - if you're looking for a pure Kotlin solution then the http4k MCP SDK has supported Streamable HTTP since May. Or if you don't mind java based then there always spring/micronaut/quarkus and co...
t
Looking to plug into an existing ktor server I’m afraid. Koog does not implement its own mcp logic. The norm is to interop with the kotlin sdk. I think the kotlin sdk is blocked on the ktor issue as outlined in the pr linked above. Bit of a circular dependency. Spring has not released a streamable http server transport either. It’s in a non stable release so coming soon, much like the kotlin sdk.
d
Really? Wow. It's only been ... 6 months now? 🙄
t
d
This surprises me more because I swear I've seen promotional videos claiming that spring MCP is ready for prod deployments... which SSE definitely isn't
t
FYI I think the comments in the PR might be off the mark. IMO the SSE plugin from ktor does not need to be changed. The SSE spec states the clients should only initialize SSE via GET methods, so the SSE plugin which operates at a routing level is correct. I think the PR needs to implement initiating SSE from the post calls outside of the ktor SSE plugin.
d
Streamable http uses a post with a accept type of either application JSON or Event Stream depending on what you want back. There is also an SSE get if you want to resume or subscribe to a stream
t
Yep, setting up a sse get is doable with the ktor plugin, I have that working and I have the post endpoint working with application/json.
The missing piece is the post endpoint working with an event stream.
d
Does it do the MCP handshake negotiation as well - there are a bunch of bits in the MCP spec around that so you may find that LLM clients incompatible if it doesn't
t
Yep it does the initialization.
I have it working with the kotlin mcp client streamable transport for non event stream responses. The sse get route just rejects requests with 405 in that case. But the client handles this.
d
Also needed for that version of the spec is Auth. MCP requires oauth with protected resource metadata (although you could use an MCP bridge with basic/apikey/bearer at a pinch)
t
Using existing auth flows at the moment which includes oauth. We don’t have dynamic client registration at the moment so looking into that.
Could you expand on how an mcp bridge would work?
d
thank you color 1