2025-10-23 16:28:23 +08:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Typography,
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
Grid,
|
|
|
|
|
IconButton,
|
|
|
|
|
Menu,
|
|
|
|
|
MenuItem,
|
|
|
|
|
Checkbox,
|
|
|
|
|
Pagination,
|
|
|
|
|
CircularProgress,
|
|
|
|
|
Snackbar,
|
|
|
|
|
Alert,
|
|
|
|
|
TextField,
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogActions
|
|
|
|
|
} from '@mui/material';
|
|
|
|
|
import {
|
|
|
|
|
Add as AddIcon,
|
|
|
|
|
MoreVert as MoreVertIcon,
|
|
|
|
|
Delete as DeleteIcon,
|
|
|
|
|
FileDownload as ExportIcon,
|
|
|
|
|
FileUpload as ImportIcon,
|
|
|
|
|
Search as SearchIcon,
|
|
|
|
|
Edit as EditIcon
|
|
|
|
|
} from '@mui/icons-material';
|
|
|
|
|
import { styled } from '@mui/material/styles';
|
|
|
|
|
import { useMcpSetting } from '@/hooks/setting-hooks';
|
|
|
|
|
import McpDialog from '@/pages/setting/components/McpDialog';
|
|
|
|
|
import type { IMcpServer } from '@/interfaces/database/mcp';
|
|
|
|
|
import type { IImportMcpServersRequestBody, ICreateMcpServerRequestBody, ITestMcpRequestBody } from '@/interfaces/request/mcp';
|
|
|
|
|
import { useMessage } from '@/hooks/useSnackbar';
|
2025-10-27 14:41:58 +08:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2025-10-23 16:28:23 +08:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
const PageContainer = styled(Box)(({ theme }) => ({
|
|
|
|
|
padding: theme.spacing(3),
|
|
|
|
|
maxWidth: '1200px',
|
|
|
|
|
margin: '0 auto',
|
|
|
|
|
backgroundColor: '#f5f5f5',
|
|
|
|
|
minHeight: '100vh'
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const PageHeader = styled(Box)(({ theme }) => ({
|
|
|
|
|
display: 'flex',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
padding: theme.spacing(2),
|
|
|
|
|
backgroundColor: theme.palette.background.paper,
|
|
|
|
|
borderRadius: theme.shape.borderRadius,
|
|
|
|
|
boxShadow: theme.shadows[1],
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const SearchContainer = styled(Box)(({ theme }) => ({
|
|
|
|
|
display: 'flex',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
padding: theme.spacing(2),
|
|
|
|
|
backgroundColor: theme.palette.background.paper,
|
|
|
|
|
borderRadius: theme.shape.borderRadius,
|
|
|
|
|
boxShadow: theme.shadows[1],
|
|
|
|
|
marginTop: theme.spacing(2),
|
|
|
|
|
marginBottom: theme.spacing(2),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function McpSettingPage() {
|
2025-10-27 14:41:58 +08:00
|
|
|
const { t } = useTranslation();
|
2025-10-23 17:14:59 +08:00
|
|
|
|
|
|
|
|
const handleRefreshServer = async (initial?: boolean) => {
|
|
|
|
|
if (initial) {
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
} else {
|
|
|
|
|
await fetchMcpServers({
|
|
|
|
|
page: currentPage,
|
|
|
|
|
size: pageSize,
|
|
|
|
|
keyword: searchString,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-23 16:28:23 +08:00
|
|
|
const {
|
|
|
|
|
mcpServers,
|
|
|
|
|
loading,
|
|
|
|
|
total,
|
|
|
|
|
fetchMcpServers,
|
|
|
|
|
importMcpServers,
|
|
|
|
|
exportMcpServers,
|
|
|
|
|
testMcpServer,
|
|
|
|
|
getMcpServerDetail,
|
|
|
|
|
createMcpServer,
|
|
|
|
|
updateMcpServer,
|
|
|
|
|
deleteMcpServer,
|
2025-10-23 17:14:59 +08:00
|
|
|
batchDeleteMcpServers,
|
|
|
|
|
} = useMcpSetting({ refreshServer: handleRefreshServer });
|
2025-10-23 16:28:23 +08:00
|
|
|
|
|
|
|
|
// 本地状态
|
|
|
|
|
const [searchString, setSearchString] = useState('');
|
|
|
|
|
const [selectedServers, setSelectedServers] = useState<string[]>([]);
|
|
|
|
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
|
|
|
const [selectedServerId, setSelectedServerId] = useState<string | null>(null);
|
|
|
|
|
const [mcpDialogOpen, setMcpDialogOpen] = useState(false);
|
|
|
|
|
const [editingServer, setEditingServer] = useState<Partial<IMcpServer> | undefined | null>(null);
|
|
|
|
|
const [importDialogOpen, setImportDialogOpen] = useState(false);
|
|
|
|
|
const [currentPage, setCurrentPage] = useState(1);
|
2025-10-23 17:14:59 +08:00
|
|
|
const [pageSize] = useState(8);
|
2025-10-23 16:28:23 +08:00
|
|
|
const [importJson, setImportJson] = useState('');
|
|
|
|
|
|
|
|
|
|
const showMessage = useMessage()
|
|
|
|
|
|
|
|
|
|
// 初始化加载数据
|
|
|
|
|
useEffect(() => {
|
2025-10-23 17:14:59 +08:00
|
|
|
fetchMcpServers({
|
|
|
|
|
page: currentPage,
|
|
|
|
|
size: pageSize,
|
|
|
|
|
keyword: searchString,
|
|
|
|
|
});
|
|
|
|
|
}, [fetchMcpServers, currentPage, pageSize, searchString]);
|
2025-10-23 16:28:23 +08:00
|
|
|
|
2025-10-23 17:14:59 +08:00
|
|
|
const totalPages = Math.ceil(total / pageSize);
|
|
|
|
|
const paginatedServers = mcpServers.slice(
|
2025-10-23 16:28:23 +08:00
|
|
|
(currentPage - 1) * pageSize,
|
|
|
|
|
currentPage * pageSize
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
setSearchString(event.target.value);
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSelectServer = (serverId: string) => {
|
|
|
|
|
setSelectedServers(prev =>
|
|
|
|
|
prev.includes(serverId)
|
|
|
|
|
? prev.filter(id => id !== serverId)
|
|
|
|
|
: [...prev, serverId]
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSelectAll = () => {
|
|
|
|
|
if (selectedServers.length === paginatedServers.length) {
|
|
|
|
|
setSelectedServers([]);
|
|
|
|
|
} else {
|
|
|
|
|
setSelectedServers(paginatedServers.map(server => server.id));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleMenuClick = (event: React.MouseEvent<HTMLElement>, serverId: string) => {
|
|
|
|
|
setAnchorEl(event.currentTarget);
|
|
|
|
|
setSelectedServerId(serverId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleMenuClose = () => {
|
|
|
|
|
setAnchorEl(null);
|
|
|
|
|
setSelectedServerId(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleEdit = async () => {
|
|
|
|
|
// const server = mcpServers.find(s => s.id === selectedServerId);
|
|
|
|
|
const result = await getMcpServerDetail(selectedServerId || '');
|
|
|
|
|
if (result.success) {
|
|
|
|
|
const server = result.data;
|
|
|
|
|
if (server != null && server != undefined) {
|
|
|
|
|
const headers = server?.headers || {};
|
|
|
|
|
const authorization_token = headers['authorization_token'] || '';
|
|
|
|
|
if (authorization_token && authorization_token.length > 0) {
|
|
|
|
|
server!.variables = {
|
|
|
|
|
...server?.variables,
|
|
|
|
|
authorization_token,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setEditingServer(server);
|
|
|
|
|
setMcpDialogOpen(true);
|
|
|
|
|
}
|
|
|
|
|
handleMenuClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
setEditingServer(null);
|
|
|
|
|
setMcpDialogOpen(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDelete = async () => {
|
|
|
|
|
if (selectedServerId) {
|
|
|
|
|
const result = await deleteMcpServer(selectedServerId);
|
|
|
|
|
if (result.success) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.success(t('mcp.deleteSuccess'));
|
2025-10-23 16:28:23 +08:00
|
|
|
} else {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.error(t('mcp.deleteFailed'));
|
2025-10-23 16:28:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
handleMenuClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleBulkDelete = async () => {
|
2025-10-23 17:14:59 +08:00
|
|
|
const result = await batchDeleteMcpServers(selectedServers);
|
2025-10-23 16:28:23 +08:00
|
|
|
if (result.success) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.success(t('mcp.batchDeleteSuccess'));
|
2025-10-23 16:28:23 +08:00
|
|
|
setSelectedServers([]);
|
|
|
|
|
} else {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.error(t('mcp.batchDeleteFailed'));
|
2025-10-23 16:28:23 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleExport = async () => {
|
|
|
|
|
const result = await exportMcpServers(selectedServers);
|
|
|
|
|
if (result.success) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.success(t('mcp.exportSuccess'));
|
2025-10-23 16:28:23 +08:00
|
|
|
} else {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.error(t('mcp.exportFailed'));
|
2025-10-23 16:28:23 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleMcpSave = async (data: ICreateMcpServerRequestBody) => {
|
|
|
|
|
try {
|
|
|
|
|
if (editingServer) {
|
|
|
|
|
if (!editingServer.id) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.error(t('mcp.serverIdRequired'));
|
2025-10-23 16:28:23 +08:00
|
|
|
return { success: false, error: 'server id 不能为空' };
|
|
|
|
|
}
|
|
|
|
|
const result = await updateMcpServer({ ...data, mcp_id: editingServer.id ?? '' });
|
|
|
|
|
if (result.success) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.success(t('mcp.mcpServerUpdateSuccess'));
|
2025-10-23 16:28:23 +08:00
|
|
|
setMcpDialogOpen(false);
|
|
|
|
|
setEditingServer(null);
|
|
|
|
|
return result;
|
|
|
|
|
} else {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const result = await createMcpServer(data);
|
|
|
|
|
if (result.success) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.success(t('mcp.mcpServerCreateSuccess'));
|
2025-10-23 16:28:23 +08:00
|
|
|
setMcpDialogOpen(false);
|
|
|
|
|
setEditingServer(null);
|
|
|
|
|
return result;
|
|
|
|
|
} else {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
const errorMessage = error.message || '操作失败';
|
|
|
|
|
return { success: false, error: errorMessage };
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleTestMcpServer = async (data: ITestMcpRequestBody) => {
|
|
|
|
|
try {
|
|
|
|
|
const result = await testMcpServer(data);
|
|
|
|
|
if (result.success) {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.success(t('mcp.testSuccess'));
|
2025-10-23 16:28:23 +08:00
|
|
|
return result;
|
|
|
|
|
} else {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
const errorMessage = error.message || '操作失败';
|
|
|
|
|
return { success: false, error: errorMessage };
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleImport = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const importData = JSON.parse(importJson);
|
|
|
|
|
if (importData.mcpServers) {
|
|
|
|
|
const requestData: IImportMcpServersRequestBody = {
|
|
|
|
|
mcpServers: Object.entries(importData.mcpServers).reduce((acc, [key, value]: [string, any]) => {
|
|
|
|
|
acc[key] = {
|
|
|
|
|
type: value.type,
|
|
|
|
|
url: value.url,
|
|
|
|
|
authorization_token: value.authorization_token || ''
|
|
|
|
|
};
|
|
|
|
|
return acc;
|
|
|
|
|
}, {} as any)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const result = await importMcpServers(requestData);
|
|
|
|
|
if (result.success) {
|
|
|
|
|
setImportDialogOpen(false);
|
|
|
|
|
setImportJson('');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2025-10-27 14:41:58 +08:00
|
|
|
showMessage.error(t('mcp.jsonFormatError'));
|
2025-10-23 16:28:23 +08:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
showMessage.error('JSON 格式错误');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-20 18:25:44 +08:00
|
|
|
return (
|
2025-10-23 16:28:23 +08:00
|
|
|
<PageContainer>
|
|
|
|
|
<PageHeader>
|
|
|
|
|
<Box>
|
2025-10-27 14:41:58 +08:00
|
|
|
<Typography variant="h5" component="h1" fontWeight="bold">
|
|
|
|
|
{t('mcp.mcpServers')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Typography>
|
2025-10-27 14:41:58 +08:00
|
|
|
<Typography variant="body2" color="text.secondary">
|
|
|
|
|
{t('mcp.customizeTheListOfMcpServers')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box display="flex" gap={2}>
|
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
startIcon={<ImportIcon />}
|
|
|
|
|
onClick={() => setImportDialogOpen(true)}
|
|
|
|
|
>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.import')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
startIcon={<AddIcon />}
|
|
|
|
|
onClick={handleAdd}
|
|
|
|
|
>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.addMCP')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</PageHeader>
|
|
|
|
|
|
|
|
|
|
<SearchContainer>
|
2025-10-23 17:14:59 +08:00
|
|
|
<Box>
|
2025-10-23 16:28:23 +08:00
|
|
|
<TextField
|
|
|
|
|
size="small"
|
2025-10-27 14:41:58 +08:00
|
|
|
placeholder={t('mcp.searchPlaceholder')}
|
2025-10-23 16:28:23 +08:00
|
|
|
value={searchString}
|
|
|
|
|
onChange={handleSearchChange}
|
|
|
|
|
InputProps={{
|
|
|
|
|
startAdornment: <SearchIcon sx={{ mr: 1, color: 'text.secondary' }} />
|
|
|
|
|
}}
|
|
|
|
|
sx={{ width: 300 }}
|
|
|
|
|
/>
|
2025-10-23 17:14:59 +08:00
|
|
|
</Box>
|
2025-10-23 16:28:23 +08:00
|
|
|
{selectedServers.length > 0 && (
|
|
|
|
|
<Box display="flex" gap={1}>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
startIcon={<DeleteIcon />}
|
|
|
|
|
onClick={handleBulkDelete}
|
2025-10-27 14:41:58 +08:00
|
|
|
disabled={selectedServers.length === 0}
|
2025-10-23 16:28:23 +08:00
|
|
|
>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.deleteSelected')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
startIcon={<ExportIcon />}
|
|
|
|
|
onClick={handleExport}
|
2025-10-27 14:41:58 +08:00
|
|
|
disabled={selectedServers.length === 0}
|
2025-10-23 16:28:23 +08:00
|
|
|
>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.exportSelected')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
</SearchContainer>
|
|
|
|
|
|
|
|
|
|
{loading ? (
|
|
|
|
|
<Box display="flex" justifyContent="center" alignItems="center" minHeight="400px">
|
|
|
|
|
<CircularProgress />
|
|
|
|
|
</Box>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<Grid container spacing={3}>
|
|
|
|
|
{paginatedServers.map((server) => (
|
|
|
|
|
<Grid size={{ xs: 6, sm: 4, md: 3 }} key={server.id}>
|
|
|
|
|
<Card
|
|
|
|
|
sx={{
|
|
|
|
|
height: '100%',
|
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
position: 'relative',
|
|
|
|
|
border: selectedServers.includes(server.id) ? '2px solid #1976d2' : '1px solid #e0e0e0'
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CardContent sx={{ flexGrow: 1 }}>
|
|
|
|
|
<Box display="flex" alignItems="center" justifyContent="space-between" mb={1}>
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={selectedServers.includes(server.id)}
|
|
|
|
|
onChange={() => handleSelectServer(server.id)}
|
|
|
|
|
size="small"
|
|
|
|
|
/>
|
|
|
|
|
<IconButton
|
|
|
|
|
size="small"
|
|
|
|
|
onClick={(e) => handleMenuClick(e, server.id)}
|
|
|
|
|
>
|
|
|
|
|
<MoreVertIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
<Typography variant="h6" component="h3" gutterBottom>
|
|
|
|
|
{server.name}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography variant="body2" color="text.secondary" gutterBottom>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.type')}: {server.server_type}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Typography>
|
|
|
|
|
<Typography variant="body2" color="text.secondary">
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.updateTime')}: {dayjs(server.update_date).format('YYYY-MM-DD HH:mm:ss')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Typography>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</Grid>
|
|
|
|
|
))}
|
|
|
|
|
</Grid>
|
|
|
|
|
|
|
|
|
|
{/* 分页 */}
|
|
|
|
|
<Box display="flex" justifyContent="center" alignItems="center" mt={3}>
|
|
|
|
|
<Pagination
|
|
|
|
|
count={totalPages}
|
|
|
|
|
page={currentPage}
|
|
|
|
|
onChange={(_, page) => setCurrentPage(page)}
|
|
|
|
|
color="primary"
|
|
|
|
|
/>
|
|
|
|
|
<Typography variant="body2" sx={{ ml: 2 }}>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.totalItems', { count: total })}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* 操作菜单 */}
|
|
|
|
|
<Menu
|
|
|
|
|
anchorEl={anchorEl}
|
|
|
|
|
open={Boolean(anchorEl)}
|
|
|
|
|
onClose={handleMenuClose}
|
|
|
|
|
>
|
|
|
|
|
<MenuItem onClick={handleEdit}>
|
|
|
|
|
<EditIcon sx={{ mr: 1 }} fontSize="small" />
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('common.edit')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem onClick={handleDelete} sx={{ color: 'error.main' }}>
|
|
|
|
|
<DeleteIcon sx={{ mr: 1 }} fontSize="small" />
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('common.delete')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</MenuItem>
|
|
|
|
|
</Menu>
|
|
|
|
|
|
|
|
|
|
{/* MCP 对话框 */}
|
|
|
|
|
<McpDialog
|
|
|
|
|
open={mcpDialogOpen}
|
|
|
|
|
onClose={() => {
|
|
|
|
|
setMcpDialogOpen(false);
|
|
|
|
|
setEditingServer(null);
|
|
|
|
|
}}
|
|
|
|
|
onSave={handleMcpSave}
|
|
|
|
|
onTest={handleTestMcpServer}
|
|
|
|
|
initialData={editingServer || {}}
|
|
|
|
|
mode={editingServer ? 'edit' : 'create'}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* 导入对话框 */}
|
|
|
|
|
<Dialog open={importDialogOpen} onClose={() => setImportDialogOpen(false)} maxWidth="md" fullWidth>
|
2025-10-27 14:41:58 +08:00
|
|
|
<DialogTitle>{t('mcp.importTitle')}</DialogTitle>
|
2025-10-23 16:28:23 +08:00
|
|
|
<DialogContent>
|
|
|
|
|
<Alert severity="info" sx={{ mb: 2 }}>
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.importDescription')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Alert>
|
|
|
|
|
<TextField
|
|
|
|
|
fullWidth
|
|
|
|
|
multiline
|
|
|
|
|
rows={10}
|
2025-10-27 14:41:58 +08:00
|
|
|
label={t('mcp.jsonConfiguration')}
|
2025-10-23 16:28:23 +08:00
|
|
|
value={importJson}
|
|
|
|
|
onChange={(e) => setImportJson(e.target.value)}
|
|
|
|
|
placeholder={`{
|
|
|
|
|
"mcpServers": {
|
|
|
|
|
"Time": {
|
|
|
|
|
"type": "sse",
|
|
|
|
|
"url": "http://localhost:8080",
|
|
|
|
|
"name": "Time Server",
|
|
|
|
|
"authorization_token": "",
|
|
|
|
|
"tool_configuration": {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}`}
|
|
|
|
|
/>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
2025-10-27 14:41:58 +08:00
|
|
|
<Button onClick={() => setImportDialogOpen(false)}>{t('common.cancel')}</Button>
|
2025-10-23 16:28:23 +08:00
|
|
|
<Button onClick={handleImport} variant="contained">
|
2025-10-27 14:41:58 +08:00
|
|
|
{t('mcp.import')}
|
2025-10-23 16:28:23 +08:00
|
|
|
</Button>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</PageContainer>
|
2025-10-20 18:25:44 +08:00
|
|
|
);
|
|
|
|
|
}
|