feat: get_api_detail 增加备注和示例返回#8
Open
sevenstars0 wants to merge 1 commit into
Open
Conversation
986b813 to
fbec490
Compare
从文档 markdown section 中提取备注和示例代码,补充到 get_api_detail 的返回结果中。 - 新增 _api_section_map 缓存 API名称→文档section映射 - 新增 _parse_notes_and_example 解析备注和示例 - server.py 输出格式化新增备注和示例展示 - 单条结果时去除冗余的二级标题 覆盖: 745个API有备注(41%), 1419个API有示例(78%) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fbec490 to
d4c9fb8
Compare
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.
改动说明
get_api_detail原来只返回从 JSON 文件提取的描述、参数、返回值,缺少文档中的备注和示例,容易导致大模型在创建组件工厂时写错CreateXXXXX这部分。本次改动从 markdown 文档 section 中解析并补充这两项信息。
修改文件
modsdk_mcp/docs_reader.py:新增_api_section_map映射、_parse_notes_and_example()解析方法,get_api_detail()返回结果增加 notes 和 example 字段modsdk_mcp/server.py:工具描述更新,输出格式化新增备注和示例展示数据覆盖
效果对比
改动后,使用get_api_detail查询LockCamera返回值示例: