agentscope-ai / agentscope-ai/QwenPaw
[Feature]: MCP 工具名称在聊天界面显示原始名称,以及文件卡片默认展开优化
- Dominant language
- Python
- Stars
- 34.9k
- Forks
- 3.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 225
Description
## Summary
MCP 工具名称显示优化:界面显示原始人类可读名称,模型调用使用清洗后名称。同时优化文件卡片默认展开。
## Component(s) Affected
- [✅️] Core / Backend (app, agents, config, providers, utils, local_models)
- [✅️] Console (frontend web UI)
- [ ] Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
- [ ] Skills
- [ ] CLI
- [ ] Documentation (website)
- [ ] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy
## Problem / Motivation
MCP 允许工具名称包含 . 、 / 、 : 等字符,但 OpenAI 风格 API 要求工具名称必须匹配 ^[a-zA-Z0-9_-]+$ 。工具名称已经做了清洗以兼容模型调用,但界面现在显示的是清洗后的名称(如 filesystem_read_file ),用户无法识别。另外,SendFileCard 默认是折叠状态,用户需要点击才能看到发送的文件。
## Proposed Solution
为工具添加 sanitized_name 字段:
- 模型使用 sanitized_name 调用(符合正则要求)
- 界面显示原始 name (人类可读)
- 后端代理在调用时将 sanitized_name 翻译回原始名称
同时为 ToolCardShell 添加 defaultOpen 属性,并设置 SendFileCard 默认展开。
## Alternatives Considered
方案一:添加原始名称字段 — 保持 name 为清洗后名称,新增 original_name 字段供前端显示。缺点是所有前端显示逻辑都需要修改。
方案二:添加清洗后字段(采用) — 保持 name 为原始名称,新增 sanitized_name 仅用于模型调用。前端无需修改显示逻辑,改动最小。
## Additional Context
修改文件清单:
- src/qwenpaw/app/mcp/stateful_client.py — 工具名称清洗、包装、代理
- src/qwenpaw/app/routers/mcp.py — API 返回 sanitized_name
- console/src/api/types/mcp.ts — 类型定义
- console/src/pages/Agent/MCP/components/MCPClientCard.tsx — 白名单使用 sanitized_name
- console/src/plugins/hostExternals.ts — 工具名称映射存储
- console/src/pages/Chat/HostBubbles.tsx — 聊天页面工具名称翻译
- console/src/pages/Chat/index.tsx — 页面初始化加载映射
- console/src/components/Chat/ToolCards/shared/ToolCardShell.tsx — 增加 defaultOpen 属性
- console/src/components/Chat/ToolCards/cards/SendFileCard.tsx — 文件卡片默认展开
## Willing to Contribute
- [✅️] I am willing to open a PR for this feature (after discussion).
Contributor guide
Assessment
This issue has not been assessed yet.