Feat: List MCP servers #3221 (#8730)

### What problem does this PR solve?

Feat: List MCP servers #3221
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-07-09 09:32:38 +08:00
committed by GitHub
parent 00c954755e
commit f7af0fc71e
13 changed files with 669 additions and 44 deletions

View File

@ -0,0 +1,49 @@
import { useSetModalState } from '@/hooks/common-hooks';
import {
useCreateMcpServer,
useGetMcpServer,
useUpdateMcpServer,
} from '@/hooks/use-mcp-request';
import { useCallback } from 'react';
export const useEditMcp = () => {
const {
visible: editVisible,
hideModal: hideEditModal,
showModal: showEditModal,
} = useSetModalState();
const { createMcpServer, loading } = useCreateMcpServer();
const { data, setId, id } = useGetMcpServer();
const { updateMcpServer } = useUpdateMcpServer();
const handleShowModal = useCallback(
(id?: string) => () => {
if (id) {
setId(id);
}
showEditModal();
},
[setId, showEditModal],
);
const handleOk = useCallback(
async (values: any) => {
if (id) {
updateMcpServer(values);
} else {
createMcpServer(values);
}
},
[createMcpServer, id, updateMcpServer],
);
return {
editVisible,
hideEditModal,
showEditModal: handleShowModal,
loading,
createMcpServer,
detail: data,
handleOk,
};
};