feat(mcp): 设置 → MCP 子页 + 策略 API + 官网/文档接入
借鉴 DBX:安装检测(Node/npm/包/Go 二进制)、只读与 allow_dangerous、 连接白名单、多客户端配置片段;GET/PUT /api/ai/mcp-policy、/mcp-install; 文档 /docs/mcp 与落地页 AI/MCP 块;对照 docs/16 勾选设置项、列仍未完清单。
This commit is contained in:
1 parent
5416e86379
commit
1513f4bc2d
20 files changed
+1567
-98
No files matched your search
+50
@@ -684,14 +684,64 @@ export type McpStatus = {
|
||||
mode: string;
|
||||
whitelistCount: number;
|
||||
writesEnabled: boolean;
|
||||
allowDangerous?: boolean;
|
||||
active: boolean;
|
||||
recent?: { time: string; tool: string; ok: boolean; summary?: string; error?: string; source?: string }[];
|
||||
policyPath?: string;
|
||||
};
|
||||
|
||||
export type McpPolicy = {
|
||||
allowed_connection_ids: string[];
|
||||
mode: "read_only" | "read_write" | string;
|
||||
allow_dangerous?: boolean;
|
||||
default_limit?: number;
|
||||
max_limit?: number;
|
||||
};
|
||||
|
||||
export type McpInstallInfo = {
|
||||
status: "ready" | "partial" | "not_installed" | string;
|
||||
installed: boolean;
|
||||
currentVersion?: string;
|
||||
latestVersion?: string;
|
||||
nodeVersion?: string;
|
||||
npmAvailable: boolean;
|
||||
npmVersion?: string;
|
||||
npmPackageInstalled: boolean;
|
||||
npmPackageVersion?: string;
|
||||
goBinaryFound: boolean;
|
||||
goBinaryPath?: string;
|
||||
installCommand: string;
|
||||
npxCommand?: string;
|
||||
policyPath?: string;
|
||||
hint?: string;
|
||||
};
|
||||
|
||||
export async function getMcpStatus(signal?: AbortSignal) {
|
||||
return get<McpStatus>("/api/ai/mcp-status", signal);
|
||||
}
|
||||
|
||||
export async function getMcpPolicy(signal?: AbortSignal) {
|
||||
return get<{ policy: McpPolicy; path?: string }>("/api/ai/mcp-policy", signal);
|
||||
}
|
||||
|
||||
export async function saveMcpPolicy(policy: McpPolicy, signal?: AbortSignal) {
|
||||
const res = await fetch(`${API}/api/ai/mcp-policy`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json", ...authHeaders() },
|
||||
body: JSON.stringify(policy),
|
||||
signal,
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
throw new Error((data as { error?: string }).error || res.statusText || "request failed");
|
||||
}
|
||||
return data as { ok: boolean; policy: McpPolicy; path?: string };
|
||||
}
|
||||
|
||||
export async function getMcpInstall(signal?: AbortSignal) {
|
||||
return get<McpInstallInfo>("/api/ai/mcp-install", signal);
|
||||
}
|
||||
|
||||
export async function confirmAiAgentWrite(payload: {
|
||||
connectionId: string;
|
||||
sql?: string;
|
||||
|
||||
Reference in new issue
Block a user