Skip to content

Add resource_templates support to MCP resource discovery#795

Open
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67:fix/issue-582-resource-templates
Open

Add resource_templates support to MCP resource discovery#795
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67:fix/issue-582-resource-templates

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

Problem

The MCP manager has two issues with resource template handling:

  1. Server detection (connection_server): Only list_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)

  2. Resource listing (execute_function): The list_resources tool only calls session.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

  • In connection_server: Also check list_resource_templates() when list_resources() returns empty, so servers with only resource templates are properly detected.
  • In execute_function: When listing resources, also call list_resource_templates() and include templates in the output alongside resources.

Changes

  • qwen_agent/tools/mcp_manager.py: Two fixes in MCPClient class.

Fixes #582
Fixes #581

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants