Add resource_templates support to MCP resource discovery#795
Open
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Open
Add resource_templates support to MCP resource discovery#795Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Conversation
The MCP manager only checked list_resources() when detecting if a server has resources, and only returned resources (not resource_templates) when listing. This caused servers with only resource_templates to be undetected, and resource templates to be missing from list_resources output. Fix both by also calling list_resource_templates() in connection_server and execute_function. Fixes QwenLM#582 Fixes QwenLM#581
This was referenced Mar 1, 2026
omarhamou
approved these changes
Mar 6, 2026
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.
Problem
The MCP manager has two issues with resource template handling:
Server detection (
connection_server): Onlylist_resources()is checked when detecting if a server has resources. Servers that only provide resource_templates are not detected, so their resource tools are never registered. (Fixes tools/mcp_manager.py没有识别全是resource_template的mcpserver #581)Resource listing (
execute_function): Thelist_resourcestool only callssession.list_resources()and doesn't include resource templates in the output, making the resource list incomplete for the LLM. (Fixes tools/mcp_manager.py执行list_resources时没有采集resource_template方法描述 #582)Fix
connection_server: Also checklist_resource_templates()whenlist_resources()returns empty, so servers with only resource templates are properly detected.execute_function: When listing resources, also calllist_resource_templates()and include templates in the output alongside resources.Changes
qwen_agent/tools/mcp_manager.py: Two fixes inMCPClientclass.Fixes #582
Fixes #581