Skip to content

[Agents] Create/Edit Agent 支持自定义 MCP 双模式选择器并移除自定义工具入口 #217

Description

@pxguan

背景

#214 / PR #216 为 Create/Edit Agent 增加了共享的 Rendered Tools 编辑器。CMA 官方的 Add MCP server 使用 Popover 展示 Directory 候选名称和 URL,但没有自定义 MCP 的 Name/URL 表单;任意 MCP URL 主要通过 Raw、Quickstart 对话或接口配置。

OMA 需要在保留官方 Directory 交互的同时,让用户无需手写 Raw 即可配置未收录的远程 MCP 服务。

目标

  • Create 与 Edit Agent 共用 Directory / 自定义 MCP 双页签选择器。
  • 移除 Rendered 模式的 Add custom tool 新增入口。
  • 保留 Raw、后端合同以及已有 Custom Tool 的编辑和删除能力。
  • MCP Server 与同名 MCP toolset 始终原子增删。

预期交互

Directory

  • Add MCP server 打开 Popover,默认选中 Directory 页签。
  • 支持搜索并展示 Directory Server 的名称、URL 和图标。
  • 选择后关闭 Popover,生成现有 MCP 卡片。
  • Directory 加载失败时展示重试状态,但不阻止切换到自定义 MCP。

自定义 MCP

  • 在同一 Popover 的自定义 MCP 页签填写 Name 和 MCP Server URL。
  • Name trim 后必填、最长 255,在当前 Agent 内大小写敏感且唯一。
  • URL trim 后必填、最长 2048,必须是带 host 的 HTTP/HTTPS 绝对地址。
  • 成功时原子添加 mcp_servers 与同名 mcp_toolset,默认权限为 always_ask。
  • 创建阶段不探测自定义 MCP 工具列表,只提供 Toolset 级权限。
  • 自定义 MCP 添加后仅支持权限配置和原子移除;修改 Name/URL 时移除后重新添加。
  • 切换页签保留临时输入;关闭、取消或按 Escape 清空临时输入,不修改 Draft,也不关闭外层 Agent 弹窗。

Custom Tool

  • Rendered 不再显示 Add custom tool 按钮。
  • Raw、模板或已有 Agent 中合法的 Custom Tool 继续无损往返,并可在 Rendered 中编辑或移除。
  • 不改变后端 Agent API 对 type=custom 工具的支持。

验收标准

  • Create/Edit 都不再展示 Add custom tool。
  • Directory 与自定义 MCP 可在同一 Popover 内切换。
  • Directory 失败不影响自定义 MCP。
  • 空值、超长、重复名称、非法协议和 20 个上限均阻止写入并展示明确错误。
  • 添加和移除不会产生单边 mcp_servers 或 mcp_toolset。
  • 自定义 MCP 进入 Create/Update 请求并默认 always_ask。
  • 关闭、取消或 Escape 不污染 Draft,且外层 Agent 弹窗保持打开。
  • 原有 Directory MCP 与已有 Custom Tool 流程不回归。
  • 中英文、键盘、浅深主题、窄屏、测试、格式检查和生产构建通过。

关联

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions