feat(mcp): inline presets in panel with one-click enable

- Show not-installed MCP presets directly in the list, consistent with existing UI (no modal)
- Toggle now supports enabling presets by writing to ~/.claude.json (mcpServers) and refreshing list
- Keep installed MCP entries unchanged (edit/delete/toggle)

fix(mcp): robust error handling and pre-submit validation

- Use extractErrorMessage in MCP panel and form to surface backend details
- Prevent pasting full config (with mcpServers) into single-server JSON field
- Add required-field checks: stdio requires non-empty command; http requires non-empty url

i18n: add messages for single-server validation and preset labels

chore: add data-only MCP presets file (no new dependencies)
This commit is contained in:
Jason
2025-10-09 17:21:03 +08:00
parent 2bb847cb3d
commit 0be596afb5
5 changed files with 214 additions and 36 deletions

38
src/config/mcpPresets.ts Normal file
View File

@@ -0,0 +1,38 @@
import { McpServer } from "../types";
export type McpPreset = {
id: string;
name: string;
description: string;
tags?: string[];
server: McpServer;
homepage?: string;
docs?: string;
requiresEnv?: string[];
};
// 预设库(数据文件,当前未接入 UI便于后续“一键启用”
export const mcpPresets: McpPreset[] = [
{
id: "github-issues",
name: "GitHub Issues",
description: "查询与管理 GitHub Issues示例",
tags: ["productivity", "dev"],
server: { type: "http", url: "https://mcp.example.com/github-issues" },
docs: "https://example.com/mcp/github-issues",
requiresEnv: ["GITHUB_TOKEN"],
},
{
id: "local-notes",
name: "本地笔记",
description: "访问本地笔记数据库(示例)",
tags: ["local"],
server: {
type: "stdio",
command: "/usr/local/bin/notes-mcp",
args: ["--db", "~/.notes/notes.db"],
},
},
];
export default mcpPresets;