🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: support install sreamable http mcp server on web (#10044)
Shinji-Li85454c5e7cb2
diff --git a/packages/types/src/discover/mcp.ts b/packages/types/src/discover/mcp.tsindex 543c6c1fb7c..bee2e5d2a3c 100644--- a/packages/types/src/discover/mcp.ts+++ b/packages/types/src/discover/mcp.ts@@ -39,10 +39,16 @@ export enum McpNavKey {Version = 'version',}+export enum McpConnectionType {+ http = 'http',+ stdio = 'stdio'+}+export type DiscoverMcpItem = PluginItem;export interface McpQueryParams {category?: string;+ connectionType?: McpConnectionType;locale?: string;order?: 'asc' | 'desc';page?: number;diff --git a/packages/types/src/plugins/mcp.ts b/packages/types/src/plugins/mcp.tsindex 732ac41f048..6b7d4d1e261 100644--- a/packages/types/src/plugins/mcp.ts+++ b/packages/types/src/plugins/mcp.ts@@ -3,6 +3,7 @@ import { z } from 'zod';import { MCPErrorType } from '@/libs/mcp';+import { McpConnectionType } from '../discover/mcp';import { CustomPluginMetadata } from '../tool/plugin';/* eslint-disable typescript-sort-keys/string-enum */@@ -110,7 +111,9 @@ export interface CheckMcpInstallResult {}>;}-export type MCPPluginListParams = Pick<PluginQueryParams, 'locale' | 'pageSize' | 'page' | 'q'>;+export type MCPPluginListParams = Pick<PluginQueryParams, 'locale' | 'pageSize' | 'page' | 'q'> & {+ connectionType?: McpConnectionType;+};export interface MCPErrorInfoMetadata {errorLog?: string;diff --git a/src/features/MCP/utils.test.ts b/src/features/MCP/utils.test.tsnew file mode 100644index 00000000000..4e32403f0b8--- /dev/null+++ b/src/features/MCP/utils.test.ts@@ -0,0 +1,91 @@+import { describe, expect, it } from 'vitest';++import { genServerConfig } from './utils';++describe('genServerConfig', () => {+ it('should generate HTTP MCP server config with url', () => {+ const result = genServerConfig('context7', {+ type: 'http',+ url: 'https://mcp.context7.com/mcp',+ } as any);++ const config = JSON.parse(result);++ expect(config).toEqual({+ mcpServers: {+ context7: {+ url: 'https://mcp.context7.com/mcp',+ },+ },+ });+ });++ it('should generate stdio MCP server config with command and args', () => {+ const result = genServerConfig('github', {+ args: ['-y', '@modelcontextprotocol/server-github'],+ command: 'npx',+ type: 'stdio',+ } as any);++ const config = JSON.parse(result);++ expect(config).toEqual({+ mcpServers: {+ github: {+ args: ['-y', '@modelcontextprotocol/server-github'],+ command: 'npx',+ },+ },+ });+ });++ it('should handle empty connection config', () => {+ const result = genServerConfig('test-plugin', {} as any);++ const config = JSON.parse(result);++ expect(config).toEqual({+ mcpServers: {+ 'test-plugin': {+ args: [],+ command: {},+ },+ },+ });+ });++ it('should handle undefined connection', () => {+ const result = genServerConfig('test-plugin', undefined);++ const config = JSON.parse(result);++ expect(config).toEqual({+ mcpServers: {+ 'test-plugin': {+ args: [],+ command: {},+ },+ },+ });+ });++ it('should prioritize url over command/args when both exist', () => {+ const result = genServerConfig('hybrid', {+ args: ['arg1'],+ command: 'cmd',+ type: 'http',+ url: 'https://example.com/mcp',+ } as any);++ const config = JSON.parse(result);++ // Should only include url, not command/args+ expect(config).toEqual({+ mcpServers: {+ hybrid: {+ url: 'https://example.com/mcp',+ },+ },+ });+ });+});diff --git a/src/features/MCP/utils.ts b/src/features/MCP/utils.tsindex d23816ff163..986f909f111 100644--- a/src/features/MCP/utils.ts+++ b/src/features/MCP/utils.ts@@ -1,7 +1,24 @@import { ConnectionConfig, DeploymentOption } from '@lobehub/market-types';-export const genServerConfig = (identifier?: string, connection?: ConnectionConfig) =>- JSON.stringify(+export const genServerConfig = (identifier?: string, connection?: ConnectionConfig) => {+ // 检查是否为 HTTP 类型+ if (connection?.url) {+ // HTTP 类型配置+ return JSON.stringify(+ {+ mcpServers: {+ [String(identifier)]: {+ url: connection.url,+ },+ },+ },+ null,+ 2,+ );+ }++ // stdio 类型配置+ return JSON.stringify({mcpServers: {[String(identifier)]: {@@ -13,6 +30,7 @@ export const genServerConfig = (identifier?: string, connection?: ConnectionConfnull,2,);+};export const getRecommendedDeployment = (deploymentOptions: DeploymentOption[]) =>deploymentOptions?.find((item) => item.isRecommended) || deploymentOptions?.[0];diff --git a/src/features/PluginStore/Content.tsx b/src/features/PluginStore/Content.tsxindex eab391d06fb..7e0b4d7d0c0 100644--- a/src/features/PluginStore/Content.tsx+++ b/src/features/PluginStore/Content.tsx@@ -4,7 +4,6 @@ import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';import { Flexbox } from 'react-layout-kit';-import { isDesktop } from '@/const/version';import { useServerConfigStore } from '@/store/serverConfig';import { useToolStore } from '@/store/tool';import { PluginStoreTabs } from '@/store/tool/slices/oldStore';@@ -22,7 +21,7 @@ export const Content = memo(() => {const [keywords] = useState<string>();const options = [- isDesktop ? { label: t('store.tabs.mcp'), value: PluginStoreTabs.MCP } : undefined,+ { label: t('store.tabs.mcp'), value: PluginStoreTabs.MCP },{ label: t('store.tabs.old'), value: PluginStoreTabs.Plugin },{ label: t('store.tabs.installed'), value: PluginStoreTabs.Installed },].filter(Boolean) as SegmentedOptions;@@ -45,7 +44,7 @@ export const Content = memo(() => {value={listType}variant={'filled'}/>- <AddPluginButton />+ {mobile ? null : <AddPluginButton />}</Flexbox><Search /></Flexbox>diff --git a/src/features/PluginStore/McpList/index.tsx b/src/features/PluginStore/McpList/index.tsxindex 6a11d9675ae..479f3ff6775 100644--- a/src/features/PluginStore/McpList/index.tsx+++ b/src/features/PluginStore/McpList/index.tsx@@ -5,7 +5,7 @@ import { memo, useRef } from 'react';import { Flexbox } from 'react-layout-kit';import { useToolStore } from '@/store/tool';-+import { useServerConfigStore } from '@/store/serverConfig';import DetailLoading from './Detail/Loading';import List from './List';@@ -15,6 +15,8 @@ export const MCPPluginList = memo(() => {const ref = useRef<HTMLDivElement>(null);const theme = useTheme();+ const mobile = useServerConfigStore((s) => s.isMobile);+return (<Flexboxheight={'75vh'}@@ -26,7 +28,9 @@ export const MCPPluginList = memo(() => {}}width={'100%'}>- <DraggablePanel maxWidth={1024} minWidth={420} placement={'left'}>+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}+ {/* @ts-ignore */}+ <DraggablePanel maxWidth={1024} minWidth={mobile ? '100vw' : 420} placement={'left'}><ListsetIdentifier={(identifier) => {useToolStore.setState({ activeMCPIdentifier: identifier });diff --git a/src/server/routers/lambda/market/index.ts b/src/server/routers/lambda/market/index.tsindex 8915c492b5c..dbd27e058fe 100644--- a/src/server/routers/lambda/market/index.ts+++ b/src/server/routers/lambda/market/index.ts@@ -3,10 +3,10 @@ import { serialize } from 'cookie';import debug from 'debug';import { z } from 'zod';-import { isDesktop } from '@/const/version';+import { isDesktop } from '@lobechat/const';import { publicProcedure, router } from '@/libs/trpc/lambda';import { DiscoverService } from '@/server/services/discover';-import { AssistantSorts, McpSorts, ModelSorts, PluginSorts, ProviderSorts } from '@/types/discover';+import { AssistantSorts, McpConnectionType, McpSorts, ModelSorts, PluginSorts, ProviderSorts } from '@/types/discover';const log = debug('lambda-router:market');@@ -83,6 +83,7 @@ export const marketRouter = router({z.object({category: z.string().optional(),+ connectionType: z.nativeEnum(McpConnectionType).optional(),locale: z.string().optional(),order: z.enum(['asc', 'desc']).optional(),page: z.number().optional(),@@ -178,6 +179,7 @@ export const marketRouter = router({z.object({category: z.string().optional(),+ connectionType: z.nativeEnum(McpConnectionType).optional(),locale: z.string().optional(),order: z.enum(['asc', 'desc']).optional(),page: z.number().optional(),diff --git a/src/services/mcp.ts b/src/services/mcp.tsindex 6402118a8aa..ea25bdeb10b 100644--- a/src/services/mcp.ts+++ b/src/services/mcp.ts@@ -41,10 +41,44 @@ class MCPService {if (!plugin) return;+ const connection = plugin.customParams?.mcp;+ const settingsEntries = plugin.settings+ ? Object.entries(plugin.settings as Record<string, any>).filter(+ ([, value]) => value !== undefined && value !== null,+ )+ : [];+ const pluginSettings =+ settingsEntries.length > 0+ ? settingsEntries.reduce<Record<string, unknown>>((acc, [key, value]) => {+ acc[key] = value;++ return acc;+ }, {})+ : undefined;++ const params = {+ ...connection,+ name: identifier,+ } as any;++ if (connection?.type === 'http') {+ params.headers = {+ ...connection.headers,+ ...pluginSettings,+ };+ }++ if (connection?.type === 'stdio') {+ params.env = {+ ...connection?.env,+ ...pluginSettings,+ };+ }+const data = {args,- env: plugin.settings || plugin.customParams?.mcp?.env,- params: { ...plugin.customParams?.mcp, name: identifier } as any,+ env: connection?.type === 'stdio' ? params.env : pluginSettings ?? connection?.env,+ params,toolName: apiName,};@@ -93,10 +127,10 @@ class MCPService {callDurationMs,customPluginInfo: isCustomPlugin? {- avatar: plugin.manifest?.meta.avatar,- description: plugin.manifest?.meta.description,- name: plugin.manifest?.meta.title,- }+ avatar: plugin.manifest?.meta.avatar,+ description: plugin.manifest?.meta.description,+ name: plugin.manifest?.meta.title,+ }: undefined,errorCode,errorMessage,diff --git a/src/store/tool/slices/mcpStore/action.test.ts b/src/store/tool/slices/mcpStore/action.test.tsindex a2406ee842d..0e9f61da128 100644--- a/src/store/tool/slices/mcpStore/action.test.ts+++ b/src/store/tool/slices/mcpStore/action.test.ts@@ -20,6 +20,44 @@ vi.mock('@/utils/sleep', () => ({sleep: vi.fn().mockResolvedValue(undefined),}));+const ORIGINAL_DESKTOP_ENV = process.env.NEXT_PUBLIC_IS_DESKTOP_APP;++const bootstrapToolStoreWithDesktop = async (isDesktopEnv: boolean) => {+ vi.resetModules();+ vi.mock('zustand/traditional');+ process.env.NEXT_PUBLIC_IS_DESKTOP_APP = isDesktopEnv ? '1' : '0';++ vi.doMock('@lobechat/const', async () => {+ const actual = await vi.importActual<typeof import('@lobechat/const')>('@lobechat/const');+ return {+ ...actual,+ isDesktop: isDesktopEnv,+ };+ });++ const storeModule = await import('@/store/tool');+ const discoverModule = await import('@/services/discover');+ const helpersModule = await import('@/store/global/helpers');++ const cleanup = () => {+ vi.resetModules();+ vi.doUnmock('@lobechat/const');+ vi.mock('zustand/traditional');+ if (ORIGINAL_DESKTOP_ENV === undefined) {+ delete process.env.NEXT_PUBLIC_IS_DESKTOP_APP;+ } else {+ process.env.NEXT_PUBLIC_IS_DESKTOP_APP = ORIGINAL_DESKTOP_ENV;+ }+ };++ return {+ useToolStore: storeModule.useToolStore,+ discoverService: discoverModule.discoverService,+ globalHelpers: helpersModule.globalHelpers,+ cleanup,+ };+};+beforeEach(() => {vi.clearAllMocks();@@ -48,6 +86,14 @@ afterEach(() => {vi.restoreAllMocks();});+afterAll(() => {+ if (ORIGINAL_DESKTOP_ENV === undefined) {+ delete process.env.NEXT_PUBLIC_IS_DESKTOP_APP;+ } else {+ process.env.NEXT_PUBLIC_IS_DESKTOP_APP = ORIGINAL_DESKTOP_ENV;+ }+});+describe('mcpStore actions', () => {describe('updateMCPInstallProgress', () => {it('should update install progress for an identifier', () => {@@ -487,7 +533,9 @@ describe('mcpStore actions', () => {expect(result.current.data).toEqual(mockData);});- expect(discoverService.getMCPPluginList).toHaveBeenCalledWith({ page: 1, pageSize: 20 });+ expect(discoverService.getMCPPluginList).toHaveBeenCalledWith(+ expect.objectContaining({ page: 1, pageSize: 20, connectionType: 'http' }),+ );const state = useToolStore.getState();expect(state.mcpPluginItems).toEqual(mockData.items);@@ -542,7 +590,9 @@ describe('mcpStore actions', () => {renderHook(() => useToolStore.getState().useFetchMCPPluginList(params));await waitFor(() => {- expect(discoverService.getMCPPluginList).toHaveBeenCalledWith(params);+ expect(discoverService.getMCPPluginList).toHaveBeenCalledWith(+ expect.objectContaining({ ...params, connectionType: 'http' }),+ );});});@@ -561,9 +611,51 @@ describe('mcpStore actions', () => {renderHook(() => useToolStore.getState().useFetchMCPPluginList(params));await waitFor(() => {- expect(discoverService.getMCPPluginList).toHaveBeenCalledWith(params);+ expect(discoverService.getMCPPluginList).toHaveBeenCalledWith(+ expect.objectContaining({ ...params, connectionType: 'http' }),+ );});});++ it('should not append connectionType in desktop environment', async () => {+ const {+ useToolStore: desktopStore,+ discoverService: desktopDiscoverService,+ globalHelpers: desktopGlobalHelpers,+ cleanup,+ } = await bootstrapToolStoreWithDesktop(true);++ const mockData = {+ items: [{ identifier: 'desktop-plugin', name: 'Desktop Plugin' }] as PluginItem[],+ categories: [],+ totalCount: 1,+ totalPages: 1,+ currentPage: 1,+ pageSize: 20,+ };++ try {+ vi.spyOn(desktopGlobalHelpers, 'getCurrentLanguage').mockReturnValue('en-US');+ const fetchSpy = vi+ .spyOn(desktopDiscoverService, 'getMCPPluginList')+ .mockResolvedValue(mockData);++ const { result } = renderHook(() =>+ desktopStore.getState().useFetchMCPPluginList({ page: 1, pageSize: 20 }),+ );++ await waitFor(() => {+ expect(result.current.data).toEqual(mockData);+ });++ expect(fetchSpy).toHaveBeenCalledTimes(1);+ const [firstCallArgs] = fetchSpy.mock.calls[0];+ expect(firstCallArgs).toMatchObject({ page: 1, pageSize: 20 });+ expect(firstCallArgs.connectionType).toBeUndefined();+ } finally {+ cleanup();+ }+ });});describe('installMCPPlugin', () => {diff --git a/src/store/tool/slices/mcpStore/action.ts b/src/store/tool/slices/mcpStore/action.tsindex 02195c9fb9f..faebb06981c 100644--- a/src/store/tool/slices/mcpStore/action.ts+++ b/src/store/tool/slices/mcpStore/action.ts@@ -1,19 +1,21 @@import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';import { PluginItem, PluginListResponse } from '@lobehub/market-sdk';import { TRPCClientError } from '@trpc/client';+import debug from 'debug';import { produce } from 'immer';import { uniqBy } from 'lodash-es';import { gt, valid } from 'semver';import useSWR, { SWRResponse } from 'swr';import { StateCreator } from 'zustand/vanilla';-import { CURRENT_VERSION } from '@/const/version';+import { CURRENT_VERSION, isDesktop } from '@lobechat/const';import { MCPErrorData } from '@/libs/mcp/types';import { discoverService } from '@/services/discover';import { mcpService } from '@/services/mcp';import { pluginService } from '@/services/plugin';import { globalHelpers } from '@/store/global/helpers';import { mcpStoreSelectors } from '@/store/tool/selectors';+import { McpConnectionType } from '@/types/discover';import {CheckMcpInstallResult,MCPErrorInfo,@@ -28,8 +30,41 @@ import { setNamespace } from '@/utils/storeDebug';import { ToolStore } from '../../store';import { MCPStoreState } from './initialState';+const log = debug('lobe-mcp:store:action');+const n = setNamespace('mcpStore');+const doesConfigSchemaRequireInput = (configSchema?: any) => {+ if (!configSchema) return false;++ const hasRequiredArray =+ Array.isArray(configSchema.required) && configSchema.required.some(Boolean);++ const hasRequiredProperty =+ !!configSchema.properties &&+ Object.values(configSchema.properties).some(+ (property: any) => property && property.required === true,+ );++ return hasRequiredArray || hasRequiredProperty;+};++const toNonEmptyStringRecord = (input?: Record<string, any>) => {+ if (!input) return undefined;++ const entries = Object.entries(input).filter(+ ([, value]) => value !== undefined && value !== null,+ );++ if (entries.length === 0) return undefined;++ return entries.reduce<Record<string, string>>((acc, [key, value]) => {+ acc[key] = typeof value === 'string' ? value : String(value);++ return acc;+ }, {});+};+// 测试连接结果类型export interface TestMcpConnectionResult {error?: string;@@ -101,6 +136,7 @@ export const createMCPPluginStoreSlice: StateCreator<installMCPPlugin: async (identifier, options = {}) => {const { resume = false, config, skipDepsCheck } = options;+ const normalizedConfig = toNonEmptyStringRecord(config);let plugin = mcpStoreSelectors.getPluginById(identifier)(get());if (!plugin || !plugin.manifestUrl) {@@ -149,12 +185,8 @@ export const createMCPPluginStoreSlice: StateCreator<}data = configInfo.manifest;- connection = {- ...configInfo.connection,- config, // 合并用户提供的配置- };+ connection = configInfo.connection ? { ...configInfo.connection } : undefined;result = configInfo.checkResult;- connection = configInfo.connection;} else {// 正常模式:从头开始安装@@ -175,59 +207,137 @@ export const createMCPPluginStoreSlice: StateCreator<install: true,});- // 步骤 2: 检查安装环境- updateMCPInstallProgress(identifier, {- progress: 30,- step: MCPInstallStep.CHECKING_INSTALLATION,+ const deploymentOptions: any[] = Array.isArray(data.deploymentOptions)+ ? data.deploymentOptions+ : [];++ const httpOption = deploymentOptions.find(+ (option) => option?.connection?.url && option?.connection?.type === 'http',+ ) ||+ deploymentOptions.find(+ (option) => option?.connection?.url && !option?.connection?.type,+ );++ const hasNonHttpDeployment = deploymentOptions.some((option) => {+ const type = option?.connection?.type;+ if (!type && option?.connection?.url) return false;++ return type && type !== 'http';});- // 检查是否已被取消- if (abortController.signal.aborted) {- return;- }+ const shouldUseHttpDeployment = !!httpOption && (!hasNonHttpDeployment || !isDesktop);- result = await mcpService.checkInstallation(data, abortController.signal);+ if (shouldUseHttpDeployment && httpOption) {+ // ✅ HTTP 类型:跳过系统依赖检查,直接使用 URL+ log('HTTP MCP detected, skipping system dependency check');- if (!result.success) {- updateMCPInstallProgress(identifier, undefined);- return;- }+ connection = {+ auth: httpOption.connection?.auth || { type: 'none' },+ headers: httpOption.connection?.headers,+ type: 'http',+ url: httpOption.connection?.url,+ };++ log('Using HTTP connection: %O', { type: connection.type, url: connection.url });- // 步骤 3: 检查系统依赖是否满足- if (!skipDepsCheck && !result.allDependenciesMet) {- // 依赖不满足,暂停安装流程并显示依赖安装引导+ const configSchema = httpOption.connection?.configSchema;+ const needsConfig = doesConfigSchemaRequireInput(configSchema);++ if (needsConfig && !normalizedConfig) {+ updateMCPInstallProgress(identifier, {+ configSchema,+ connection,+ manifest: data,+ needsConfig: true,+ progress: 50,+ step: MCPInstallStep.CONFIGURATION_REQUIRED,+ });++ updateInstallLoadingState(identifier, undefined);+ return false;+ }+ } else {+ // ❌ stdio 类型:需要完整的系统依赖检查流程++ // 步骤 2: 检查安装环境updateMCPInstallProgress(identifier, {- connection: result.connection,- manifest: data,- progress: 40,- step: MCPInstallStep.DEPENDENCIES_REQUIRED,- systemDependencies: result.systemDependencies,+ progress: 30,+ step: MCPInstallStep.CHECKING_INSTALLATION,});- // 暂停安装流程,等待用户安装依赖- updateInstallLoadingState(identifier, undefined);- return false; // 返回 false 表示需要安装依赖+ // 检查是否已被取消+ if (abortController.signal.aborted) {+ return;+ }++ result = await mcpService.checkInstallation(data, abortController.signal);++ if (!result.success) {+ updateMCPInstallProgress(identifier, undefined);+ return;+ }++ // 步骤 3: 检查系统依赖是否满足+ if (!skipDepsCheck && !result.allDependenciesMet) {+ // 依赖不满足,暂停安装流程并显示依赖安装引导+ updateMCPInstallProgress(identifier, {+ connection: result.connection,+ manifest: data,+ progress: 40,+ step: MCPInstallStep.DEPENDENCIES_REQUIRED,+ systemDependencies: result.systemDependencies,+ });++ // 暂停安装流程,等待用户安装依赖+ updateInstallLoadingState(identifier, undefined);+ return false; // 返回 false 表示需要安装依赖+ }++ // 步骤 4: 检查是否需要配置+ if (result.needsConfig) {+ // 需要配置,暂停安装流程+ updateMCPInstallProgress(identifier, {+ checkResult: result,+ configSchema: result.configSchema,+ connection: result.connection,+ manifest: data,+ needsConfig: true,+ progress: 50,+ step: MCPInstallStep.CONFIGURATION_REQUIRED,+ });++ // 暂停安装流程,等待用户配置+ updateInstallLoadingState(identifier, undefined);+ return false; // 返回 false 表示需要配置+ }++ connection = result.connection;}+ }- // 步骤 4: 检查是否需要配置- if (result.needsConfig) {- // 需要配置,暂停安装流程- updateMCPInstallProgress(identifier, {- checkResult: result,- configSchema: result.configSchema,- connection: result.connection,- manifest: data,- needsConfig: true,- progress: 50,- step: MCPInstallStep.CONFIGURATION_REQUIRED,- });+ let mergedHttpHeaders: Record<string, string> | undefined;+ let mergedStdioEnv: Record<string, string> | undefined;++ if (connection?.type === 'http') {+ const baseHeaders = toNonEmptyStringRecord(connection.headers);- // 暂停安装流程,等待用户配置- updateInstallLoadingState(identifier, undefined);- return false; // 返回 false 表示需要配置+ if (baseHeaders || normalizedConfig) {+ mergedHttpHeaders = {+ ...baseHeaders,+ ...normalizedConfig,+ };}+ }++ if (connection?.type === 'stdio') {+ const baseEnv = toNonEmptyStringRecord(connection.env);- connection = result.connection;+ if (baseEnv || normalizedConfig) {+ mergedStdioEnv = {+ ...baseEnv,+ ...normalizedConfig,+ };+ }}// 获取服务器清单逻辑@@ -251,7 +361,7 @@ export const createMCPPluginStoreSlice: StateCreator<{args: connection.args,command: connection.command!,- env: config,+ env: mergedStdioEnv,name: identifier, // 将配置作为环境变量传递(resume 模式下)},{ avatar: plugin.icon, description: plugin.description, name: data.name },@@ -261,6 +371,8 @@ export const createMCPPluginStoreSlice: StateCreator<if (connection?.type === 'http') {manifest = await mcpService.getStreamableMcpServerManifest({+ auth: connection.auth,+ headers: mergedHttpHeaders,identifier,metadata: {avatar: plugin.icon,@@ -318,7 +430,7 @@ export const createMCPPluginStoreSlice: StateCreator<customParams: { mcp: connection },identifier: plugin.identifier,manifest: manifest,- settings: config,+ settings: normalizedConfig,type: 'plugin',});@@ -347,7 +459,7 @@ export const createMCPPluginStoreSlice: StateCreator<resources: (manifest as any).resources,tools: (manifest as any).tools,},- platform: result!.platform,+ platform: result?.platform || process.platform,success: true,userAgent,version: manifest.version || data.version,@@ -423,7 +535,7 @@ export const createMCPPluginStoreSlice: StateCreator<installDurationMs,installParams: connection,metadata: errorInfo.metadata,- platform: result!.platform,+ platform: result?.platform || process.platform,success: false,userAgent,version: data?.version,@@ -581,10 +693,22 @@ export const createMCPPluginStoreSlice: StateCreator<useFetchMCPPluginList: (params) => {const locale = globalHelpers.getCurrentLanguage();+ const requestParams = isDesktop ? params : { ...params, connectionType: McpConnectionType.http };+ const swrKeyParts = [+ 'useFetchMCPPluginList',+ locale,+ requestParams.page,+ requestParams.pageSize,+ requestParams.q,+ requestParams.connectionType,+ ];+ const swrKey = swrKeyParts.filter((part) => part !== undefined && part !== null && part !== '')+ .join('-');+ const page = requestParams.page ?? 1;return useSWR<PluginListResponse>(- ['useFetchMCPPluginList', locale, ...Object.values(params)].filter(Boolean).join('-'),- () => discoverService.getMCPPluginList(params),+ swrKey,+ () => discoverService.getMCPPluginList(requestParams),{onSuccess(data) {set(@@ -602,7 +726,7 @@ export const createMCPPluginStoreSlice: StateCreator<}// 累积数据逻辑- if (params.page === 1) {+ if (page === 1) {// 第一页,直接设置draft.mcpPluginItems = uniqBy(data.items, 'identifier');} else {diff --git a/src/store/tool/slices/oldStore/initialState.ts b/src/store/tool/slices/oldStore/initialState.tsindex da7216e0a03..ef9a9572c79 100644--- a/src/store/tool/slices/oldStore/initialState.ts+++ b/src/store/tool/slices/oldStore/initialState.ts@@ -1,4 +1,3 @@-import { isDesktop } from '@/const/version';import { DiscoverPluginItem } from '@/types/discover';export type PluginInstallLoadingMap = Record<string, boolean | undefined>;@@ -47,7 +46,7 @@ export const initialPluginStoreState: PluginStoreState = {// Plugin list state management initial valuescurrentPluginPage: 1,displayMode: 'grid',- listType: isDesktop ? PluginStoreTabs.MCP : PluginStoreTabs.Plugin,+ listType: PluginStoreTabs.MCP,oldPluginItems: [],pluginInstallLoading: {},pluginInstallProgress: {},