Skip to content

OAuth Redirect URL: Missing in Docs? #388

@bene-we

Description

@bene-we

Hey @danny-avila , first of all huge thanks to your contributions to LibreChat! This helps us a lot in moving forward quickly.

While working with the Spotify MCP example, we ran into some unclear points:

  1. registeredClients is set in the code but never actually used anywhere else. Could you clarify its intended purpose and how/where it should be consumed? Right now, we worked around this by not using Dynamic Client Registration (and setting the OAuth settings in librechat.yaml)
  2. The redirect URL pattern "/api/mcp//oauth/callback" from Authentication Server back to LibreChat does not seem to be documented anywhere, we had to debug it locally from the Spotify example to get OAuth working with LibreChat. Can you confirm if this is the intended callback path? If yes and you can help me spot the correct location, I can create a PR for the docs
  3. Following point 2, we are redirected into LibreChat successfully and access_token / refresh_token are being stored successfully in the DB. Still, our MCP does not receive the access_token and does not seem to store it, I wasn't able to to spot how this works in the Spotify MCP. Could you give me a hint to work this out as well?

Right now, we connected LibreChat directly to the Authentication Server (not through the MCP):

mcpServers:
  sf-mcp:
      type: "streamable-http"
      url: "https://mcp.example.com/mcp"
      headers:
        X-User-ID: "{{LIBRECHAT_USER_ID}}"
      startup: true
      oauth:
        authorization_url: https://oauth-provider.example.com/services/oauth2/authorize
        token_url: https://oauth-provider.example.com/services/oauth2/token
  
        client_id: <clientId>
        client_secret: <clientSecret>
  
        redirect_uri: "https://librechat.example.com/api/mcp/sf-mcp/oauth/callback"
        scope: "api refresh_token"

This flow works until we are redirected to LibreChat, afterwards Prompts to the MCP fail due to missing authorisation (point 3 mentioned above). We previously tried to set respective MCP endpoints in this config and route everything through the MCP (like in the spotify example), which we couldn't get to work because we couldn't get the access_token from the MCP back to LibreChat.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions