Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function, _modelscope_mcp_transport_from_url_info, to dynamically determine the MCP transport type for ModelScope servers based on provided URL information, replacing a previously hardcoded value. Unit tests were added to verify the new logic. Feedback suggests expanding the test suite to include scenarios where transport details are provided as nested dictionaries, ensuring that the implementation's handling of mapping types is fully covered and protected against regressions.
| [ | ||
| ({"transport": "Streamable HTTP", "url": "https://example.com/mcp"}, "streamable_http"), | ||
| ({"transport_type": "sse", "url": "https://example.com/mcp"}, "sse"), | ||
| ({"type": "streamable_http", "url": "https://example.com/mcp"}, "streamable_http"), | ||
| ({"url": "https://example.com/mcp/sse"}, "sse"), | ||
| ({"url": "https://example.com/mcp"}, "streamable_http"), | ||
| ], |
There was a problem hiding this comment.
The test coverage for _modelscope_mcp_transport_from_url_info is good, but it's missing cases for when the transport value is a nested dictionary. The implementation at astrbot/core/provider/func_tool_manager.py:152-153 handles this scenario, so it would be beneficial to add test cases for it to prevent future regressions. Specifically, the logic handling Mapping types (checking for type or name keys) is not covered. Please consider adding test cases to cover this path.
[
({"transport": "Streamable HTTP", "url": "https://example.com/mcp"}, "streamable_http"),
({"transport_type": "sse", "url": "https://example.com/mcp"}, "sse"),
({"type": "streamable_http", "url": "https://example.com/mcp"}, "streamable_http"),
({"transport": {"type": "sse"}, "url": "https://example.com/mcp"}, "sse"),
({"protocol": {"name": "Streamable HTTP"}, "url": "https://example.com/mcp"}, "streamable_http"),
({"url": "https://example.com/mcp/sse"}, "sse"),
({"url": "https://example.com/mcp"}, "streamable_http"),
],References
- New functionality should be accompanied by corresponding unit tests.
a4c4a7d to
9bd38ca
Compare
|
Gentle ping on this ModelScope MCP transport fix. The change preserves the configured transport instead of falling back to the default path, which matters for deployments that intentionally choose the ModelScope transport. Current checks are green. Could a maintainer review when convenient? |
293e848 to
be23f36
Compare
|
Rebased onto current master to clear the conflict (the recent ModelScope MCP sync refactors touched the same function). While resolving, I updated the expected transport in |
be23f36 to
98b790b
Compare
|
在现在的 master(73b4fc9d)上又核了一遍: |
…261110 # Conflicts: # tests/unit/test_func_tool_manager.py
Linked issuesChecked at commit f6174b6 #8269 [Bug]ModelScope同步MCP服务器传输类型出错 · 1 of 1 met
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
/sseURL fallback casesFixes #8269
Test Plan
uv run pytest tests/unit/test_func_tool_manager.py::test_modelscope_mcp_transport_from_url_info -q --basetemp .tmp/pytest-modelscope-transport -o cache_dir=.tmp/pytest-cache-modelscopeuv run pytest tests/unit/test_func_tool_manager.py -q --basetemp .tmp/pytest-func-tool-manager -o cache_dir=.tmp/pytest-cache-func-tool-manageruv run ruff check astrbot/core/provider/func_tool_manager.py tests/unit/test_func_tool_manager.pypython -m py_compile astrbot/core/provider/func_tool_manager.py tests/unit/test_func_tool_manager.pygit diff --checkSummary by Sourcery
Preserve ModelScope MCP server transport types during synchronization and infer them from endpoint URLs when metadata is incomplete.
Bug Fixes:
/sseendpoints.Tests: