Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
const { CacheKeys } = require('librechat-data-provider');
const { MCPOAuthHandler, MCPTokenStorage, cleanupMCPServerOAuth } = require('@librechat/api');
const { getFlowStateManager, getMCPServersRegistry } = require('~/config');
const { getLogStores } = require('~/cache');
const db = require('~/models');
/** Revocation must still reach a server the owner's profile hides. */
const INCLUDE_HIDDEN = { includeHidden: true };
const maybeUninstallOAuthMCP = async (
userId,
pluginKey,
appConfig,
serverConfigOverride,
teardown,
) => {
const registry = getMCPServersRegistry();
return cleanupMCPServerOAuth({
userId,
pluginKey,
appConfig,
serverConfigOverride,
teardown,
dependencies: {
flowManager: getFlowStateManager(getLogStores(CacheKeys.FLOWS)),
oauthHandler: MCPOAuthHandler,
tokenStorage: MCPTokenStorage,
findToken: db.findToken,
deleteTokens: db.deleteTokens,
getServerConfig: (serverName, ownerId) =>
registry.getServerConfig(serverName, ownerId, undefined, undefined, INCLUDE_HIDDEN),
isRegisteredOAuthServer: async (serverName, ownerId) =>
(await registry.getOAuthServers(ownerId, INCLUDE_HIDDEN)).has(serverName),
},
});
};
module.exports = { maybeUninstallOAuthMCP };