Skip to content
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

sse server does not process endpoint correctly #41

Open
shendaxia-sm opened this issue Feb 11, 2025 · 0 comments
Open

sse server does not process endpoint correctly #41

shendaxia-sm opened this issue Feb 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@shendaxia-sm
Copy link

Describe the bug

mcp sse server does not remove last path when join endpoint url.
for example: baseUrl is http://localhost/sse, and server return sse data:

event:endpoint data:mesages?sessionId=a7f13c57-3ebe-4676-8079-bab962990583

sdk return endpoint http://localhost/sse/mesages?sessionId=a7f13c57-3ebe-4676-8079-bab962990583

the correct endpoint should be http://localhost/mesages?sessionId=a7f13c57-3ebe-4676-8079-bab962990583

python-sdk can correctly return the endpoint

A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

embeddedServer(CIO, host = "127.0.0.1", port = port) {
    install(SSE)
    routing {
        sse("/sse") {
            val transport = SSEServerTransport("message", this)
            val server = configureServer()

            // For SSE, you can also add prompts/tools/resources if needed:
            // server.addTool(...), server.addPrompt(...), server.addResource(...)

            servers[transport.sessionId] = server

            server.onCloseCallback = {
                println("Server closed")
                servers.remove(transport.sessionId)
            }

            server.connect(transport)
        }
        post("/message") {
            println("Received Message")
            val sessionId: String = call.request.queryParameters["sessionId"]!!
            val transport = servers[sessionId]?.transport as? SSEServerTransport
            if (transport == null) {
                call.respond(HttpStatusCode.NotFound, "Session not found")
                return@post
            }

            transport.handlePostMessage(call)
        }
    }
}.start(wait = true)

Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant