From 4fa48ff03065623c2782e91383c8ed1e48a47f7c Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 1 Sep 2026 17:35:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20.mcp.json=20?= =?UTF-8?q?=E4=B8=BA=E6=9C=AC=E9=A1=B9=E7=9B=AE=20MCP=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20+=20=E8=A1=A5=E5=85=85=E5=A4=9A=E6=BA=90=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .mcp.json 原为 Mac 上另一项目(serena)残留配置,按文档 8.2 重写为 a-share-research - 补充 test_fmt_results_multi_source_tag(验证 [多源] 展示) - MCP 服务核心(5 工具/stdio/SSE/依赖/测试)此前已实现并经端到端验证 --- .mcp.json | 13 +++---------- continuation.md | 29 +++++++++++++++++++++++++++++ tests/test_mcp.py | 12 +++++++++++- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/.mcp.json b/.mcp.json index b04d386..20ec27e 100644 --- a/.mcp.json +++ b/.mcp.json @@ -1,16 +1,9 @@ { "mcpServers": { - "serena-djapi": { + "a-share-research": { "command": "uv", - "args": [ - "run", - "--directory", - "/Users/summer/Downloads/cc-cursor/mcp-servers/serena", - "serena", - "start-mcp-server", - "--project", - "/Users/summer/Downloads/cc-projects/news" - ] + "args": ["run", "python", "-m", "scripts.run_mcp_server"], + "cwd": "/home/pi/news" } } } diff --git a/continuation.md b/continuation.md index b98dd1b..61899e1 100644 --- a/continuation.md +++ b/continuation.md @@ -4,6 +4,35 @@ --- +## 本次完成 (2026-08-23) — MCP 新闻查询服务确认与修复 + +**用户需求**:实现新闻查询 MCP 服务(阅读文档步骤,确认是否已实现)。 + +**确认结论:核心实现完整且可用(此前已实现,本次验证 + 修复一处配置错误)**: + +| 文档要求 | 现状 | 验证 | +|----------|------|------| +| `scripts/run_mcp_server.py`(stdio/SSE 入口) | ✅ 存在 | stdio 端到端调用通过 | +| `mcp_server/tools.py` 5 个工具 | ✅ 齐全 | `tools/list` 返回 5 工具,`tools/call` 真实检索成功 | +| pyproject 依赖 `mcp>=1.0` | ✅ 已声明 | 已安装 | +| `tests/test_mcp.py` | ✅ 10 个测试 | 全过 | +| `.mcp.json`(Claude Code 配置) | ❌ **配置错误** | 见下 | + +**发现并修复的差距**: +- `.mcp.json` 被跟踪的内容是 **Mac 上另一项目(serena)的残留配置**(路径指向 `/Users/summer/...`),与本项目无关 → 按 `docs/user-guide.md` 8.2 重写为 `a-share-research` 配置 +- 补充 1 个测试(`test_fmt_results_multi_source_tag`,验证 A2 多源展示) + +**端到端验证**(真实调用,非 mock): +1. 5 个工具函数直接调用:全部返回检索结果 ✓ +2. SSE 模式 `--sse 8765`:`GET /sse` 返回 `event: endpoint` 握手 ✓ +3. **MCP 协议层**(stdio 客户端 → `scripts.run_mcp_server`):`tools/list` 返回 5 个工具与文档一致;`tools/call search_news("国务院常务会议")` 命中《李强主持召开国务院常务会议》等 ✓ + +**全量测试**:283 passed(新增 1 个多源展示),3 个 crawler 基线失败与本次无关;ruff 干净 + +**遗留**:无(仅既有 reporter 5 个 ruff 问题、Qdrant 本地模式性能警告) + +--- + ## 本次完成 (2026-08-23) — P1-2/P1-3 补跑步骤与时区一致性修复 **P1-2(守护进程补跑误含 cninfo 三步)**: diff --git a/tests/test_mcp.py b/tests/test_mcp.py index 87ee7dc..e81e0c4 100644 --- a/tests/test_mcp.py +++ b/tests/test_mcp.py @@ -41,9 +41,11 @@ def _hit(title: str = "测试标题", source: str = "cls", score: float = 0.9, sentiment: str = "positive", stock_codes: list[str] | None = None, company_names: list[str] | None = None, summary: str = "摘要", publish_time: str = "2026-06-16T10:00:00", - url: str = "https://example.com/1") -> dict: + url: str = "https://example.com/1", + sources: list[str] | None = None) -> dict: return { "title": title, "url": url, "source": source, "score": score, + "sources": sources or [source], "publish_time": publish_time, "event": { "sentiment": sentiment, "importance": 4, "event_type": "重大合同", @@ -61,6 +63,14 @@ def test_fmt_results_contains_title_and_source() -> None: assert "0.9" in out +def test_fmt_results_multi_source_tag() -> None: + """多源新闻显示「来源A / 来源B [多源]」。""" + hits = [_hit("多源新闻", sources=["cls", "sina"])] + out = _fmt_results(hits, "查询") + assert "cls / sina" in out + assert "[多源]" in out + + def test_fmt_results_includes_event_fields() -> None: hits = [_hit( company_names=["宁德时代"], stock_codes=["300750"],