feat(mcp): 43 atomic tools, unified staging upload, meeting tool split, UTC timestamps#13
Merged
Merged
Conversation
…lection ID semantics 重构 MCP 模块架构,工具从 ~15 个扩展到 41 个,覆盖 8 个领域: Collections(5) Documents(7) Search(3) Tasks(5) Summaries(4) Notes(6) Meetings(6) HotWords(5) 核心变更: - 新增 7 个领域工具模块:common/tasks/notes/meetings/hot_words + 对应测试 - 新增 set_document_definitive 工具:标记文档参与 consolidate 摘要合并 - MCP 不再独立端口运行,挂载为 /mcp ASGI 子应用(与主 API 同进程) - 统一所有 22 个 collection 参数只接受 Qdrant collection ID,docstring 提示先用 list_collections 获取 - 统一使用 require_collection/ok/err/run_sync/to_json 公共工具函数 健壮性改进: - get_collection 剔除 sparse_vocab(275K→2K) - get_query_history 默认只返回 question+timestamp(155K→2K) - list_meetings 只返回轻量字段,新增 status/search 过滤(66K→3K) - get_document_text 新增 offset/limit 分页,默认 10000 字符 - get_file_chunks 修复变量遮蔽导致的 TypeError、按 char_offset 正确排序、新增 chunk_type 过滤(默认排除 child) - upload_document 描述明确是远端服务器路径 - 不支持的文件格式报错附带全量支持列表 - 修复 API 层 collection name→ID 解析,前端 upload queue 对 MCP 上传可见 BREAKING: 移除 upload_folder、sinkduce-mcp console script、mcp_port 配置
- Upload: remove upload_document/upload_document_content, unify to upload_document_from_staging with side-channel HTTP staging (zero LLM context leak)
- Staging: POST /api/mcp/upload (one-shot), /api/mcp/meeting-upload, /api/mcp/stage-content (token-based)
- Meeting: split get_meeting into get_meeting (metadata), get_section (per-tab markdown), get_meeting_transcript (paginated)
- Meeting: add upload_meeting_audio_from_staging via staging pattern
- Timezone: replace all datetime.now() with datetime.now(timezone.utc) across 10 files, backward-compat deserialization for old naive data
- Server: dynamic {base_url} injection in tool descriptions from config
- Tests: update test_mcp_server for 43-tool structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Two-commit branch that restructures the MCP server from ~15 coarse tools to 43 atomic tools across 8 domains, then fixes context-leak and overflow issues discovered in production use.
Commit 1:
52f73c8— MCP restructure (41 tools)Refactored MCP from scattered modules into 8 domain modules with 41 atomic tools.
New tool modules:
src/mcp/common.py— shared helpers (ok/err/run_sync/to_json/require_collection)src/mcp/tools/collections.py(5),documents.py(7),search.py(3)src/mcp/tools/tasks.py(5),summaries.py(4),notes.py(6)src/mcp/tools/meetings.py(6),hot_words.py(5)Key fixes:
list_collectionsfirst)get_collection: strippedsparse_vocab(275KB → 2KB)get_query_history: default returns question+timestamp only (155KB → 2KB)list_meetings: lightweight fields + status/search filtering (66KB → 3KB)get_document_text: offset/limit pagination (default 10K chars)get_file_chunks: fixed variable-shadowing TypeError, correct char_offset sorting, chunk_type filteringset_document_definitive: new tool for document-level summary opt-inArchitecture: MCP served as
/mcpASGI sub-app (same process as FastAPI), no separate port.BREAKING: removed
upload_folder,sinkduce-mcpconsole script,mcp_portconfig.Commit 2:
fedce24— Staging upload, meeting split, UTC timestamps (43 tools)Fixes discovered during production use of the 41-tool MCP server.
🔴 Context leak fix — unified staging upload:
upload_document_content(content_b64=...)leaked file bytes into LLM transcriptPOST /api/mcp/upload,/api/mcp/meeting-upload,/api/mcp/stage-contentupload_document_from_staging,upload_meeting_audio_from_stagingupload_document,upload_document_content{base_url}injection from config into tool descriptions🔴 Overflow fix — meeting tool split:
get_meetingreturned 263KB JSON (1231 transcript segments), exceeded MCP return limitget_meeting(metadata only, <2KB),get_section(tab_id),get_meeting_transcript(offset, limit)🟡 Timestamp UTC fix:
datetime.now()→datetime.now(timezone.utc)across 10 filesStats