[Enhancement]: Separate OBO authentication state from interactive MCP OAuth

Open
#18,921 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start with usesObo and the discovery fallback in packages/api/src/mcp/MCPConnectionFactory.ts (around lines 405-425), then detectOAuth() in MCPServerInspector. The generic OAuth-URL message is in api/server/services/MCP.js (around lines 1463-1485), and the health-check versus tool-call recovery split is in MCPManager.callTool and isConnected. Done means OBO-configured servers are not classified as interactive OAuth, OBO errors no longer point to an OAuth sign-in URL, and tool-call and health-check recovery behave consistently.

Written by the indexing model from the issue text.

Description

✨ enhancement
What features would you like to see added?

Follow-up to #18920, which reproduces OBO servers being classified as interactive OAuth during startup detection.

LibreChat currently makes two distinct decisions that can conflict for an OBO-configured MCP server:

  • How to connect: MCPConnectionFactory.usesObo selects OBO token exchange using the signed-in user's existing identity. OBO has its own connection path and retries once with a forced token re-exchange when a tool request is rejected.
  • Whether interactive MCP OAuth is required: MCPServerInspector.detectOAuth() can infer requiresOAuth: true from an unauthenticated Bearer challenge and protected-resource metadata. That challenge indicates the server requires a bearer token; it does not establish that the user should sign in to the MCP server interactively.

These are not two implementations of OBO. OBO intentionally shares OAuth-related connection and token plumbing: requiresOAuthMachinery() returns true for OBO so the OBO resolver is passed through. That shared plumbing should remain. The inconsistency is that some classification, discovery, and recovery paths also interpret OBO as interactive OAuth.

More details

At upstream commit 4700c44eb77c142b4f9f8b87476924f22890eb39, code review identifies these related paths:

  • MCPConnectionFactory discovery marks an OBO token-resolution failure as oauthRequired and falls back to unauthenticated tool listing (MCPConnectionFactory.ts).
  • Some auth failures reach a generic message that asks the user to check for an OAuth authentication URL (MCP.js), although OBO has no separate interactive MCP sign-in URL.
  • Health-check recovery differs from tool-call recovery. If isConnected() detects an auth failure and the server is classified as OAuth, MCPManager.callTool can enter the shared interactive OAuth recovery path. If it is not classified that way, the tool call returns “Connection is not active” without a forced OBO refresh. The tool-request 401 path has a separate OBO re-exchange/retry. This is based on code review, not a live health-check reproduction.

The request is to keep OBO's shared token plumbing while making discovery results, user-facing errors, and recovery behavior accurately reflect whether the configured mode is OBO or interactive OAuth. The startup detection behavior and controlled inspector A/B are described in #18920; the additional paths above have not been tested end-to-end.

Which components are impacted by your request?

Other — MCP server authentication.

Pictures

N/A.

Code of Conduct
  • I agree to follow this project's Code of Conduct
Dominant language
TypeScript
Stars
45.6k
Forks
9.4k
Avg merge
16h 24m
Merged PRs (30d)
825

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LibreChat-AI/LibreChat

All issues in LibreChat-AI/LibreChat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.