feat(mcp): add wiki MCP index server - #126
Open
liyc-sys wants to merge 1 commit into
Open
Conversation
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.
概述
实现 #88:给 wiki 添加 MCP 目录索引。不上传任何页面内容到外部——MCP server 只把
mkdocs.yml里那棵导航树(与 quant-wiki.com 渲染所用的同一棵)暴露成目录,Agent 先看目录、再按需读取单页。内容
新增
mcp/server.py(单文件 MCP server,stdio 传输)+mcp/README.md(接入说明),主 README 增加一节指引。三个工具:wiki_catalog():顶层分区总览(11 个分区、423 页,含每区页数);wiki_catalog(section="基本概念")列出该分区全部页面(导航标题路径 + docs 路径);wiki_search(query):大小写不敏感的标题/路径搜索,中英文都可命中(词条文件名同时带中英文,如债券_Bond.md),最多返回 50 条;wiki_page(path):按 docs 路径读取单页 markdown,输出头部带该页在 quant-wiki.com 的引用 URL;路径不在目录里时返回引导提示而不是报错。实现细节:
mcpSDK 和PyYAML,以 PEP 723 内联声明,uv run mcp/server.py即可运行,无需改动仓库现有requirements.txt;兼容mcp1.x(FastMCP)和 2.x(MCPServer)两代 API;mkdocs.yml用容忍!!python/name:扩展标签的 SafeLoader,不引入 mkdocs 依赖;server.py一个文件也能用,不必 clone 整个仓库;--check冒烟模式(打印目录统计、抽样页面、搜索结果),不需要 MCP 客户端即可验证。验证
uv run mcp/server.py --check:目录 423 页 / 11 分区解析正确,抽样页面读取与站点 URL 生成正确,搜索命中正常;initialize/list_tools(3 个工具)/ 逐个call_tool(含不存在路径的兜底提示)全部通过。Closes #88