Skip to content

Commit b030aa6

Browse files
committed
feat(mcp): 聊天工具默认使用实时数据源
- MCP 聊天、移动端上下文和搜索工具默认传递 source=auto - 工具 schema 公开 source 枚举与默认值 - 搜索结果区分实时索引与旧快照索引的新鲜度说明 - 账号信息返回 direct/decrypted 模式、db_storage、密钥和 realtime 状态 - 支持从 PyInstaller _MEIPASS 或环境变量定位 Copilot Skill - 更新 Copilot Skill 文档中的实时数据源说明 - 补充 MCP source 默认值、schema 和打包 Skill 读取测试
1 parent 176035a commit b030aa6

6 files changed

Lines changed: 435 additions & 44 deletions

File tree

skills/wechat-mcp-copilot/references/chats.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Use this for chat sessions, message search, and message context.
55
## Flow
66

77
1. Resolve fuzzy target with `wechat.chat.resolve_session`.
8-
2. For recent messages, call `wechat.chat.get_messages` with a small `limit`.
9-
3. For keywords, call `wechat.chat.search_messages`.
8+
2. For recent/latest messages, call `wechat.chat.get_messages` with a small `limit`; the default `source=auto` reads live WeChat WCDB directly.
9+
3. For keywords, call `wechat.chat.search_messages`; the default `source=auto` uses the WCDB-derived realtime FTS index. If it is still building, retry after the index status becomes ready.
1010
4. Use `wechat.chat.list_search_senders` when the user needs sender facets for a broad search.
1111
5. For a hit that needs context, call `wechat.chat.get_message_around`.
1212
6. For merged-forward chat history or AppMsg cards that only expose `server_id`, call `wechat.chat.resolve_chat_history` or `wechat.chat.resolve_app_message`.
@@ -26,3 +26,11 @@ Use this for chat sessions, message search, and message context.
2626
- `wechat.chat.resolve_app_message`
2727

2828
Do not scan full histories by pagination when an aggregate or search tool can answer.
29+
30+
## Freshness
31+
32+
- `list_sessions`, `resolve_session`, `get_messages`, `get_message_around`, `get_message_anchor`, `get_daily_message_counts`, and `search_messages` default to `source=auto`.
33+
- Use `source=realtime` only when you explicitly require live WeChat WCDB and want failure instead of fallback.
34+
- Use `source=decrypted` only for explicit legacy snapshot analysis against output databases.
35+
- `search_messages source=auto` and `list_search_senders source=auto` use the same realtime WCDB-derived index, so single-character Chinese searches should not fall back to slow bounded scans once the index is ready.
36+
- `get_message_raw` intentionally remains an output-snapshot debugging tool for raw decrypted fields.

skills/wechat-mcp-copilot/references/mobile.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ Use this for phone, ScreenMemo, and external MCP clients unless the user needs a
2222
- Do not fetch binary media through MCP. Use returned URLs in the app.
2323
- Use low-level tools only for debugging, raw fields, or unusual media URL construction.
2424
- Data preparation, index/cache build, export, realtime sync, local editing, system settings, and data deletion tools are not exposed through MCP.
25+
- Chat/session/context/calendar tools default to `source=auto` (direct live WeChat WCDB). Mobile chat search also defaults to `source=auto` and uses the WCDB-derived realtime FTS index; `source=decrypted` is only for explicit legacy output snapshots.
2526

2627
## Recovery
2728

2829
- If `ready=false`, stop content tools and direct the user to the desktop/web app for data preparation or backend diagnostics.
2930
- If target resolution is ambiguous, ask for one clarifying clue or show top candidates.
30-
- If search returns nothing, try `resolve_target` and then `get_chat_context` before declaring no data.
31+
- If search returns nothing, try `resolve_target` and then `get_chat_context` before declaring no data; `source=auto` search is backed by the realtime WCDB-derived FTS index and may need the index build to finish first.

src/wechat_decrypt_tool/mcp/registry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ def object_schema(
131131
return schema
132132

133133

134-
def string_schema(description: str, *, enum: list[str] | None = None) -> dict[str, Any]:
134+
def string_schema(description: str, *, enum: list[str] | None = None, default: str | None = None) -> dict[str, Any]:
135135
out: dict[str, Any] = {"type": "string", "description": description}
136136
if enum:
137137
out["enum"] = enum
138+
if default is not None:
139+
out["default"] = default
138140
return out
139141

140142

0 commit comments

Comments
 (0)