1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from "react";
import {
    FormDataConsumer,
    NumberInput,
    SelectInput,
    TextInput,
} from "react-admin";
import { Grid, Typography } from "@mui/material";
import StatusSelectInput from "@/page/components/StatusSelectInput";
 
const transportChoices = [
    { id: "SSE_HTTP", name: "SSE_HTTP" },
    { id: "STDIO", name: "STDIO" },
    { id: "BUILTIN", name: "BUILTIN" },
];
 
const AiMcpMountForm = ({ readOnly = false }) => (
    <Grid container spacing={2} width={{ xs: "100%", xl: "80%" }}>
        <Grid item xs={12}>
            <Typography variant="h6">MCP 挂载配置</Typography>
        </Grid>
        <Grid item xs={12} md={6}>
            <TextInput source="name" label="名称" fullWidth disabled={readOnly} />
        </Grid>
        <Grid item xs={12} md={6}>
            <SelectInput source="transportType" label="传输类型" choices={transportChoices} fullWidth disabled={readOnly} />
        </Grid>
        <FormDataConsumer>
            {({ formData }) => (
                <>
                    {formData.transportType === "BUILTIN" && (
                        <>
                            <Grid item xs={12}>
                                <SelectInput
                                    source="builtinCode"
                                    label="内置 MCP"
                                    choices={[
                                        { id: "RSF_WMS", name: "RSF_WMS" },
                                        { id: "RSF_WMS_STOCK", name: "RSF_WMS_STOCK" },
                                        { id: "RSF_WMS_TASK", name: "RSF_WMS_TASK" },
                                        { id: "RSF_WMS_BASE", name: "RSF_WMS_BASE" },
                                    ]}
                                    fullWidth
                                    disabled={readOnly}
                                />
                            </Grid>
                        </>
                    )}
                    {formData.transportType === "SSE_HTTP" && (
                        <>
                            <Grid item xs={12}>
                                <TextInput source="serverUrl" label="服务地址" fullWidth disabled={readOnly} />
                            </Grid>
                            <Grid item xs={12}>
                                <TextInput source="endpoint" label="SSE Endpoint" fullWidth disabled={readOnly} />
                            </Grid>
                            <Grid item xs={12}>
                                <TextInput source="headersJson" label="Headers JSON" fullWidth multiline minRows={4} disabled={readOnly} />
                            </Grid>
                        </>
                    )}
                    {formData.transportType === "STDIO" && (
                        <>
                            <Grid item xs={12}>
                                <TextInput source="command" label="命令" fullWidth disabled={readOnly} />
                            </Grid>
                            <Grid item xs={12}>
                                <TextInput source="argsJson" label="Args JSON" fullWidth multiline minRows={4} disabled={readOnly} />
                            </Grid>
                            <Grid item xs={12}>
                                <TextInput source="envJson" label="Env JSON" fullWidth multiline minRows={4} disabled={readOnly} />
                            </Grid>
                        </>
                    )}
                </>
            )}
        </FormDataConsumer>
        <Grid item xs={12} md={4}>
            <NumberInput source="requestTimeoutMs" label="Timeout(ms)" fullWidth disabled={readOnly} />
        </Grid>
        <Grid item xs={12} md={4}>
            <NumberInput source="sort" label="排序" fullWidth disabled={readOnly} />
        </Grid>
        <Grid item xs={12} md={4}>
            <StatusSelectInput disabled={readOnly} />
        </Grid>
        <Grid item xs={12}>
            <TextInput source="memo" label="备注" fullWidth multiline minRows={3} disabled={readOnly} />
        </Grid>
    </Grid>
);
 
export default AiMcpMountForm;