- 
                Notifications
    
You must be signed in to change notification settings  - Fork 174
 
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I can not understand how we should get information about the currently logged in user in the MCP request. We have added bearer authentication with OAuth flow for logging in to MCP, but it does not seem to be possible to pass information about the Ktor Principal or the tenant (can derive this from ApplicationCall). It seems to get lost here and I don't understand how to pass on more info here
    public suspend fun handlePostMessage(call: ApplicationCall) {
        if (!initialized.load()) {
            val message = "SSE connection not established"
            call.respondText(message, status = HttpStatusCode.InternalServerError)
            _onError.invoke(IllegalStateException(message))
        }
        val body = try {
            val ct = call.request.contentType()
            if (ct != ContentType.Application.Json) {
                error("Unsupported content-type: $ct")
            }
            call.receiveText()
        } catch (e: Exception) {
            call.respondText("Invalid message: ${e.message}", status = HttpStatusCode.BadRequest)
            _onError.invoke(e)
            return
        }
        try {
            handleMessage(body)
        } catch (e: Exception) {
            call.respondText("Error handling message $body: ${e.message}", status = HttpStatusCode.BadRequest)
            return
        }
        call.respondText("Accepted", status = HttpStatusCode.Accepted)
    }
So here we have ApplicationCall, but in handleMessage() it seems like we only have the body.
So we need a way to pass more arbitrary data. In particular:
- Ktor principal
 - Any attributes we have on the ApplicationCall
 
So having full access to ApplicationCall downstream would be great!
Many thanks
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working