Agents

Self-hosted ChatGPT for company documents: adding permission-aware search to LibreChat (2026)

Connect LibreChat to PipesHub over MCP for a self-hosted ChatGPT that answers from company documents and follows each person's permissions. Exact steps.

Connect LibreChat to PipesHub over MCP for a self-hosted ChatGPT that answers from company documents and follows each person's permissions. Exact steps.

Shekhar Kadyan

Co-founder

For most teams, the best self-hosted ChatGPT for company documents is a chat tool you run yourself, such as LibreChat, connected to PipesHub, an index that knows which documents each person is allowed to open in SharePoint, Google Drive, Confluence, Slack and 50+ other sources.


You keep the LibreChat you already run and add PipesHub over MCP, the Model Context Protocol for connecting AI tools to outside tools, so each person signs in as themselves and gets cited answers only from documents they could open anyway.


PipesHub publishes this article and is the search index we recommend and use in the steps below. LibreChat, Open WebUI and AnythingLLM are described from their own documentation, checked on 20 Nov 2026.


Key takeaways

  • "Self-hosted ChatGPT" means a chat tool such as LibreChat or Open WebUI that you run on your own servers, because ChatGPT itself cannot be self-hosted.

  • Company documents reach a chat tool at one of three levels: personal uploads, a shared knowledge base, or an index that follows each person's access in the source apps.

  • The first two levels work on copies, which lose the original's access list and go out of date.

  • LibreChat reaches the third level through MCP, because it keeps a separate sign-in for each person.

  • PipesHub is the recommended third-level index, because it checks each source's own permissions for the person asking and cites the exact block it answers from.

  • The setup takes an OAuth app in PipesHub, one MCP server entry in LibreChat, and one redirect address copied back to PipesHub.


What "self-hosted ChatGPT" can and cannot mean


ChatGPT is a hosted product, so nobody outside OpenAI can run it on their own servers. People who search for a self-hosted version usually want the same chat experience under their own control, which LibreChat, Open WebUI and AnythingLLM each provide. These tools do not come with company knowledge, so what matters is how documents get in and who can see them afterwards.


The three levels of company knowledge


Level

How documents get in

Who can see them

Stays current

1. Personal upload

A person attaches files to a chat

That person

Only if they upload again

2. Shared knowledge base

Someone uploads or syncs files into a collection

Everyone with access to the collection

Only if someone re-syncs it

3. Permission-aware index, such as PipesHub (recommended)

Connectors read the source apps and their permissions

Whoever can open the document at the source

Connectors sync on a schedule


Why uploads and shared knowledge bases lose permissions


Levels one and two both work on copies. When a file is copied out of SharePoint or Google Drive into a chat tool, the list of people allowed to open it stays behind.


Files added to an agent, which is LibreChat's name for a saved assistant, "become the agent's knowledge base: everyone who chats with the agent can have it search those files" (RAG API docs). The agents page adds, "Do not put anything in an agent that its viewers should never see" (Agents docs). That rule suits a handbook, but not a folder where finance, HR and engineering each see different files.


Copies also age. A contract renegotiated last week is still the old version in last month's upload.


A LibreChat feature request, opened on 21 June 2026 and still open on 20 Nov 2026, asks for SharePoint and OneDrive as a knowledge source. Its author lists "per-user SharePoint permission trimming" as out of scope and calls it "a fundamentally different, heavier model" (issue 13873). Following each person's access is the job of a dedicated index. PipesHub's connectors read each source's permissions along with its content, and access is checked when the query runs, for the specific person asking.


How LibreChat, Open WebUI and AnythingLLM handle documents


Tool

Licence

Built-in document search

Who sees the documents

MCP sign-in

LibreChat

MIT

File search per chat or per agent

The uploader, or everyone who can chat with the agent

Per user, with OAuth

Open WebUI

Open WebUI License

Knowledge bases, plus a sync tool

Users and groups granted read or write access

Per user, with OAuth 2.1

AnythingLLM

MIT

Documents embedded per workspace

Users added to the workspace

Headers shared by all users


LibreChat has a SharePoint file picker that works through each person's own Microsoft sign-in (SharePoint docs). The picked files are downloaded and attached to the conversation, so they become level-one copies.


Open WebUI has built-in knowledge bases that can be private, public, or shared with chosen groups and users (groups docs). A companion tool called oikb mirrors content from 44 connectors, including SharePoint, Google Drive and Confluence (oikb docs). Its documentation describes access through Open WebUI's own sharing settings, not each source's per-person permissions.


AnythingLLM organises documents into workspaces, and a default user can chat only in workspaces they have been added to (security docs). Its MCP docs say static headers "are the same for every user and workspace", with an option to forward the calling user's identity (MCP docs).


When plain file upload is enough


File upload is enough when one person works with their own files, or when a team shares a small, stable set of documents that every member may read. You need the third level when different people must get different answers to the same question, when documents change often, or when the knowledge lives in several apps.


How to add permission-aware search to LibreChat


You need a running LibreChat, a running PipesHub on Pro (PipesHub Cloud) or Enterprise (self-hosted), since permission-aware answers are in those editions, with at least one source connected, and an administrator account on PipesHub. The steps follow our LibreChat guide, with button labels from LibreChat's current MCP docs.


Diagram: a question travels from a person in LibreChat, through an MCP tool call made under that person's own sign-in, to an index that returns only passages the person may open.

How one question flows. LibreChat keeps a separate sign-in for each person, so the index always knows who is asking.

  1. Create an OAuth app in PipesHub. An OAuth app is a registration that lets another program send people to PipesHub to sign in. As an administrator, open Workspace Settings, select OAuth 2.0 Apps under Developer Settings, and click New OAuth application. Give it a name, keep the Authorization Code grant, and select the scopes listed in step 3. Scopes are the permissions the app may request.


    The form requires at least one redirect URI, the address PipesHub sends people back to after sign-in. LibreChat shows the real one only in step 5, so enter a temporary HTTPS address on your LibreChat domain for now. You will replace it in step 5. Save the app, then copy the Client ID and Client Secret. The secret is shown only once.

  2. Add the server in LibreChat. Open MCP Settings in LibreChat's side panel and click Add MCP (the + button). The button appears only if your role may create MCP servers. Fill in these fields, where Streamable HTTPS is LibreChat's label for MCP's standard web transport:


    Name:            Pipeshub
    MCP Server URL:  PIPESHUB_INSTANCE_URL/mcp
    Transport:       Streamable HTTPS
    Authentication:  OAuth
    Name:            Pipeshub
    MCP Server URL:  PIPESHUB_INSTANCE_URL/mcp
    Transport:       Streamable HTTPS
    Authentication:  OAuth
    Name:            Pipeshub
    MCP Server URL:  PIPESHUB_INSTANCE_URL/mcp
    Transport:       Streamable HTTPS
    Authentication:  OAuth
  3. Enter the OAuth details. PIPESHUB_INSTANCE_URL is the address of your PipesHub, for example https://app.pipeshub.com on PipesHub Cloud.


    Client ID:          YOUR_CLIENT_ID
    Client Secret:      YOUR_CLIENT_SECRET
    Authorization URL:  PIPESHUB_INSTANCE_URL/api/v1/oauth2/authorize
    Token URL:          PIPESHUB_INSTANCE_URL/api/v1/oauth2/token
    Scope:              openid profile email offline_access semantic:write conversation:write conversation:chat kb:read team:read user:read config:read
    Client ID:          YOUR_CLIENT_ID
    Client Secret:      YOUR_CLIENT_SECRET
    Authorization URL:  PIPESHUB_INSTANCE_URL/api/v1/oauth2/authorize
    Token URL:          PIPESHUB_INSTANCE_URL/api/v1/oauth2/token
    Scope:              openid profile email offline_access semantic:write conversation:write conversation:chat kb:read team:read user:read config:read
    Client ID:          YOUR_CLIENT_ID
    Client Secret:      YOUR_CLIENT_SECRET
    Authorization URL:  PIPESHUB_INSTANCE_URL/api/v1/oauth2/authorize
    Token URL:          PIPESHUB_INSTANCE_URL/api/v1/oauth2/token
    Scope:              openid profile email offline_access semantic:write conversation:write conversation:chat kb:read team:read user:read config:read


    The scopes must match those granted to the OAuth app in PipesHub. Leave LibreChat's Token Exchange Method field on the default, Auto.

  4. Trust and save. Tick I trust this application and click Create.

  5. Register the redirect URI. LibreChat now shows a Redirect URI in this format:


    http://localhost:3080/api/mcp/<server-identifier>/oauth/callback
    http://localhost:3080/api/mcp/<server-identifier>/oauth/callback
    http://localhost:3080/api/mcp/<server-identifier>/oauth/callback


    On a hosted LibreChat the start of the address is your own domain, for example https://chat.example.com. Copy the exact value into the redirect URIs of the PipesHub OAuth app, in place of the temporary one. PipesHub accepts only HTTPS redirect addresses, except for localhost and 127.0.0.1.

  6. Sign in. Back in LibreChat, connect the server and click Continue with OAuth. Sign in to PipesHub and approve the permissions. The tab shows Authentication Successful and the server changes to Connected.

  7. Share it and use it. The person who created the server can share it from its Edit dialog with users, groups, roles or everyone. Each person then completes step 6 with their own PipesHub account. In a chat, open the composer's + palette and click the server under MCP Servers. Pick a model that supports tool calls, or it will never call the server's tools.


The admin route: librechat.yaml


LibreChat administrators can instead define the server in librechat.yaml under mcpServers, which takes a restart to apply. The block below fills LibreChat's documented oauth format with the endpoints from our guide.


mcpServers:
  pipeshub:
    type: streamable-http
    url: PIPESHUB_INSTANCE_URL/mcp
    oauth:
      authorization_url: PIPESHUB_INSTANCE_URL/api/v1/oauth2/authorize
      token_url: PIPESHUB_INSTANCE_URL/api/v1/oauth2/token
      client_id: YOUR_CLIENT_ID
      client_secret: YOUR_CLIENT_SECRET
      redirect_uri: https://chat.example.com/api/mcp/pipeshub/oauth/callback
      scope: 'openid profile email offline_access semantic:write conversation:write conversation:chat kb:read team:read user:read config:read'
mcpServers:
  pipeshub:
    type: streamable-http
    url: PIPESHUB_INSTANCE_URL/mcp
    oauth:
      authorization_url: PIPESHUB_INSTANCE_URL/api/v1/oauth2/authorize
      token_url: PIPESHUB_INSTANCE_URL/api/v1/oauth2/token
      client_id: YOUR_CLIENT_ID
      client_secret: YOUR_CLIENT_SECRET
      redirect_uri: https://chat.example.com/api/mcp/pipeshub/oauth/callback
      scope: 'openid profile email offline_access semantic:write conversation:write conversation:chat kb:read team:read user:read config:read'
mcpServers:
  pipeshub:
    type: streamable-http
    url: PIPESHUB_INSTANCE_URL/mcp
    oauth:
      authorization_url: PIPESHUB_INSTANCE_URL/api/v1/oauth2/authorize
      token_url: PIPESHUB_INSTANCE_URL/api/v1/oauth2/token
      client_id: YOUR_CLIENT_ID
      client_secret: YOUR_CLIENT_SECRET
      redirect_uri: https://chat.example.com/api/mcp/pipeshub/oauth/callback
      scope: 'openid profile email offline_access semantic:write conversation:write conversation:chat kb:read team:read user:read config:read'


Replace https://chat.example.com with your LibreChat address. The redirect address uses the key under mcpServers, here pipeshub, so you know it before you create the OAuth app. Each person still signs in with their own PipesHub account.


Checking the connection


On the LibreChat server, run this test from our guide. It should print a 401 status, not a connection error.


curl -s -o /dev/null -w "%{http_code}\n" -X POST PIPESHUB_INSTANCE_URL/mcp
curl -s -o /dev/null -w "%{http_code}\n" -X POST PIPESHUB_INSTANCE_URL/mcp
curl -s -o /dev/null -w "%{http_code}\n" -X POST PIPESHUB_INSTANCE_URL/mcp


A redirect error means the address in the OAuth app does not exactly match the one LibreChat shows. An authorisation error usually means the scopes differ. If PipesHub runs on an internal IP address or a local hostname, LibreChat blocks it until an administrator allows it under mcpSettings in librechat.yaml (MCP settings docs).


Test that two people get different answers


A quick test with two people shows PipesHub's permission check at work. Pick a document that one test user can open at the source and another cannot, and wait for indexing to finish.


Sign in to LibreChat as the first user, complete the PipesHub sign-in, and ask a question that only that document answers. The answer should cite the document. Then ask the same question as the second user, who should get no answer from that document. If both users see it, check that each one signed in to PipesHub with their own account.


Running it with a local model


Two models are involved. LibreChat's model reads the question and decides to call a tool. It can be a local model served by Ollama, a program that runs open models on your own hardware (Ollama docs).


PipesHub uses its own configured model when the chat tool calls pipeshub_chat, the tool that returns a cited answer. PipesHub works with any LLM provider, including local models through Ollama (our Ollama guide). When every model is local, including the embedding model PipesHub uses to index text, no question or document goes to a hosted model provider, and our air-gapped install guide covers sites with no internet access at all.


Where PipesHub fits


PipesHub turns LibreChat into a self-hosted ChatGPT that knows your company. It has 50+ connectors, including SharePoint, Google Drive, Confluence, Jira and Slack. Access is checked when the query runs, against each source's own permissions, for the specific person asking, and answers cite the exact block of the source document.


PipesHub comes in three editions: the Community edition, open source under Apache 2.0 and free to self-host; Pro on PipesHub Cloud at $20 per user per month, billed yearly; and the Enterprise edition, under our Enterprise licence, which runs in your own cloud, your virtual private cloud (VPC) or fully offline (PipesHub pricing).


Permission-aware answers are in Pro and Enterprise. You can self-host the Enterprise edition with Docker Compose or Helm. PipesHub works with any LLM provider, including local models through Ollama. The same MCP server also works with Claude Code, Cursor, Claude Desktop and Gemini CLI.


PipesHub ranked #1 on the public EnterpriseRAG-Bench leaderboard (Hugging Face) as of 14 Nov 2026, with 93.24 overall (95.0% answer correctness) among 43 entries (leaderboard). Onyx runs that leaderboard.


If your shared documents are open to everyone and rarely change, the knowledge features already in LibreChat or Open WebUI may be all you need.


To get started, sign up for PipesHub Cloud at app.pipeshub.com, where every new workspace starts with a 14-day Pro trial. To run PipesHub on your own servers with permission-aware answers, choose the Enterprise edition (pricing). Our full LibreChat guide and the rest of the docs are at docs.pipeshub.com.


Watch: connecting LibreChat to PipesHub, step by step, shown in both products (4 minutes 56 seconds).


FAQ


What is a self-hosted ChatGPT?


It is a chat tool, such as LibreChat, Open WebUI or AnythingLLM, that you run on your own servers with a hosted or local model of your choice. ChatGPT itself is a hosted product and cannot be self-hosted.


Does LibreChat's file search follow SharePoint permissions?


It does so only when a person picks files. LibreChat's docs say of its SharePoint file picker, "Only files the user has permission to access in SharePoint are available". Files added to an agent can then be searched by everyone who can chat with that agent.


Can I do the same with Open WebUI?


Open WebUI has supported MCP over Streamable HTTP since version 0.6.31, with an OAuth 2.1 (Static) option for a pre-created client ID and secret (Open WebUI MCP docs). PipesHub's MCP server uses Streamable HTTP and OAuth, and our step-by-step guide is written for LibreChat, so try the Open WebUI connection on a staging instance first.


Do I need an OAuth app, or can I use a personal access token?


For LibreChat we recommend the OAuth app, because each person then signs in once in the browser and LibreChat stores that sign-in for them alone. PipesHub personal access tokens also act as the person who created them and work as a bearer token in an Authorization header. They are the route our guides use for developer tools such as Claude Code.


Does every user need a PipesHub account?


Yes, because each person signs in to PipesHub through LibreChat, and that sign-in is how the index knows whose permissions to apply. LibreChat's docs state that OAuth tokens and saved credentials are never used for anyone else.


Related reading


Sources

No headings found on page

Check out more blogs