Skip to content

feat(mcp): 43 atomic tools, unified staging upload, meeting tool split, UTC timestamps#13

Merged
superdd-coder merged 2 commits into
mainfrom
feat/mcp-restructure
Jul 14, 2026
Merged

feat(mcp): 43 atomic tools, unified staging upload, meeting tool split, UTC timestamps#13
superdd-coder merged 2 commits into
mainfrom
feat/mcp-restructure

Conversation

@superdd-coder

@superdd-coder superdd-coder commented Jul 14, 2026

Copy link
Copy Markdown
Owner

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:

  • All 22 collection parameters now accept collection ID only (docstrings guide users to list_collections first)
  • get_collection: stripped sparse_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 filtering
  • set_document_definitive: new tool for document-level summary opt-in

Architecture: MCP served as /mcp ASGI sub-app (same process as FastAPI), no separate port.

BREAKING: removed upload_folder, sinkduce-mcp console script, mcp_port config.


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:

  • Problem: upload_document_content(content_b64=...) leaked file bytes into LLM transcript
  • Solution: all uploads go through side-channel HTTP, MCP tools only pass 36-char UUID tokens
  • New endpoints: POST /api/mcp/upload, /api/mcp/meeting-upload, /api/mcp/stage-content
  • New tools: upload_document_from_staging, upload_meeting_audio_from_staging
  • Removed: upload_document, upload_document_content
  • Dynamic {base_url} injection from config into tool descriptions

🔴 Overflow fix — meeting tool split:

  • Problem: get_meeting returned 263KB JSON (1231 transcript segments), exceeded MCP return limit
  • Split into: get_meeting (metadata only, <2KB), get_section(tab_id), get_meeting_transcript(offset, limit)

🟡 Timestamp UTC fix:

  • 14 instances of datetime.now()datetime.now(timezone.utc) across 10 files
  • Backward-compatible: old naive ISO data auto-treated as UTC on deserialization

Stats

  • 19 files changed (+1244 / −233)
  • 43 MCP tools, 8 HTTP endpoints (3 staging)
  • 567 tests passed

…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
@superdd-coder superdd-coder changed the title feat(mcp): unified staging upload, meeting tool split, UTC timestamps feat(mcp): 43 atomic tools, unified staging upload, meeting tool split, UTC timestamps Jul 14, 2026
@superdd-coder
superdd-coder merged commit dd43610 into main Jul 14, 2026
4 of 6 checks passed
@superdd-coder
superdd-coder deleted the feat/mcp-restructure branch July 14, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant