Session from MCP call
I have a function on my server code that automatically filters by logged user. That's easy with
const session = auth.api.getSession({ headers })
and from there I grab the userId
Now I want to call the same function but from an MCP server. This time session
will be undefined.
I see I can use auth.api.getMcpSession({ headers })
to get the userId from an MCP call and this works fine.
So two solutions for the two usecases, that's ok.
Question: Is there a quick way to retrieve the userId regardless if this is a regular request from the browser vs a request from an MCP server? Or should I simply try the first, if undefined try the second, if undefined again I assume there's no user logged in and call it a day 😄0 Replies