{"record":{"id":"ab6b80b918f25fa1","repo":"FlowiseAI/Flowise","slug":"mcp-server-serverid-not-found","errorCode":null,"errorMessage":"MCP server ${serverId} not found","messagePattern":"MCP server (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/MCP/CustomMcpServerTool/CustomMcpServerTool.ts","lineNumber":139,"sourceCode":"            throw new Error('MCP Server is required')\n        }\n\n        const appDataSource = options.appDataSource as DataSource\n        const databaseEntities = options.databaseEntities as IDatabaseEntity\n        if (!appDataSource || !databaseEntities?.['CustomMcpServer']) {\n            throw new Error('Database not available')\n        }\n\n        const workspaceId =\n            (options.workspaceId as string | undefined) ??\n            ((options.searchOptions as ICommonObject | undefined)?.workspaceId as string | undefined)\n        if (!workspaceId) {\n            throw new Error('Workspace context is required to load MCP server')\n        }\n\n        const serverRecord = await appDataSource.getRepository(databaseEntities['CustomMcpServer']).findOneBy({ id: serverId, workspaceId })\n        if (!serverRecord) {\n            throw new Error(`MCP server ${serverId} not found`)\n        }\n        if (serverRecord.status !== 'AUTHORIZED') {\n            throw new Error(`MCP server \"${serverRecord.name}\" is not authorized. Please authorize it in the Tools page first.`)\n        }\n\n        // Build headers from encrypted authConfig — only when authType explicitly requires them\n        let headers: Record<string, string> = {}\n        if (serverRecord.authType === 'CUSTOM_HEADERS' && serverRecord.authConfig) {\n            try {\n                const decrypted = await decryptCredentialData(serverRecord.authConfig)\n                if (decrypted?.headers && typeof decrypted.headers === 'object') {\n                    headers = decrypted.headers as Record<string, string>\n                }\n            } catch {\n                // authConfig decryption failed — proceed without headers\n            }\n        }\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/MCP/CustomMcpServerTool/CustomMcpServerTool.ts#L121-L157","documentation":"Thrown by CustomMcpServerTool.getTools when the TypeORM findOneBy({ id: serverId, workspaceId }) returns null. The query is workspace-scoped, so the record appears 'not found' if the serverId doesn't exist, was deleted, OR exists in a different workspace. The serverId is echoed in the message for debugging.","triggerScenarios":"A stale node still referencing a serverId that was deleted; a serverId copied from another workspace (tenant isolation hides it); a typo/UUID truncation in the id; the server record exists but with a different casing/format that doesn't match.","commonSituations":"Deleted a server from the Tools page but the flow still references it; exported a flow from workspace A and imported into workspace B (serverIds don't exist there); copy-paste truncating the UUID.","solutions":["Open the Tools page in the correct workspace and copy the current serverId, then re-select it on the node.","If the server was deleted, recreate it and update the node reference.","For cross-workspace imports, re-create the server in the target workspace and rebind the node.","Verify the workspaceId in options matches the workspace where the server was created."],"exampleFix":"// before — stale id after deletion\nnodeData.inputs = { mcpServerId: 'old-uuid' }\n// after — current id from Tools page\nnodeData.inputs = { mcpServerId: 'new-uuid' }","handlingStrategy":"validation","validationCode":"async function assertServerExists(ds: DataSource, entity: any, serverId: string, workspaceId: string) {\n  const rec = await ds.getRepository(entity).findOneBy({ id: serverId, workspaceId })\n  if (!rec) throw new Error(`No managed MCP server '${serverId}' in workspace '${workspaceId}' — recreate or rebind`)\n  return rec\n}","typeGuard":"async function serverExists(ds: DataSource, entity: any, serverId: string, workspaceId: string): Promise<boolean> {\n  const c = await ds.getRepository(entity).countBy({ id: serverId, workspaceId })\n  return c > 0\n}","tryCatchPattern":"try {\n  return await tool.getTools(nodeData, options)\n} catch (e) {\n  if (e instanceof Error && /MCP server .* not found/.test(e.message)) {\n    return rebindToCurrentServerId(nodeData)\n  }\n  throw e\n}","preventionTips":["Re-select the server on the node after deletion/recreation.","When importing flows cross-workspace, recreate servers and rebind ids.","Verify the workspaceId matches where the server was created.","Copy serverIds from the Tools page to avoid truncation."],"tags":["mcp","database","not-found","workspace","stale-reference"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}