mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Edit MCP server #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
import message from '@/components/ui/message';
|
||||
import { IMcpServerListResponse, IMCPTool } from '@/interfaces/database/mcp';
|
||||
import {
|
||||
IMcpServer,
|
||||
IMcpServerListResponse,
|
||||
IMCPTool,
|
||||
} from '@/interfaces/database/mcp';
|
||||
import { ITestMcpRequestBody } from '@/interfaces/request/mcp';
|
||||
import i18n from '@/locales/config';
|
||||
import mcpServerService from '@/services/mcp-server-service';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useState } from 'react';
|
||||
|
||||
export const enum McpApiAction {
|
||||
ListMcpServer = 'listMcpServer',
|
||||
@ -34,20 +37,19 @@ export const useListMcpServer = () => {
|
||||
return { data, loading };
|
||||
};
|
||||
|
||||
export const useGetMcpServer = () => {
|
||||
const [id, setId] = useState('');
|
||||
const { data, isFetching: loading } = useQuery({
|
||||
export const useGetMcpServer = (id: string) => {
|
||||
const { data, isFetching: loading } = useQuery<IMcpServer>({
|
||||
queryKey: [McpApiAction.GetMcpServer, id],
|
||||
initialData: {},
|
||||
initialData: {} as IMcpServer,
|
||||
gcTime: 0,
|
||||
enabled: !!id,
|
||||
queryFn: async () => {
|
||||
const { data } = await mcpServerService.get();
|
||||
const { data } = await mcpServerService.get({ mcp_id: id });
|
||||
return data?.data ?? {};
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, setId, id };
|
||||
return { data, loading, id };
|
||||
};
|
||||
|
||||
export const useCreateMcpServer = () => {
|
||||
|
||||
Reference in New Issue
Block a user