ListMcpResourcesTool: List MCP resources
8/2/2026, 4:54:01 PM · Source
AI-translated on 8/2/2026, 4:54:56 PM · by Qwen3.6 35B (fast, default)
ListMcpResourcesTool is a resource discovery tool in the MCP ecosystem that enables models to dynamically list all available resource URIs after connecting to an MCP Server, avoiding blind guessing.
It Grants the Model "Resource Discovery Capability" First
ListMcpResourcesTool's role is much like directory browsing in a remote environment.
If the model has already connected to an MCP server but doesn't know exactly what resources are exposed there, the first step should be to use it to list them out.
Key Source Code
tools/ListMcpResourcesTool/ListMcpResourcesTool.ts:
const inputSchema = z.object({
server: z.string().optional().describe('Optional server name to filter resources by'),
})
The core logic is:
const results = await Promise.all(
clientsToProcess.map(async client => {
const fresh = await ensureConnectedClient(client)
return await fetchResourcesForClient(fresh)
}),
)
This shows that it doesn't rely on reading a static cache, but instead operates around the MCP client connection state.
Call Chain
Model needs to read MCP resource > ListMcpResourcesTool > Verify connected client > fetchResourcesForClient > Return resource list > Pass to ReadMcpResourceTool
Summary
ListMcpResourcesTool addresses the resource discovery problem; without it, the model would have to blindly guess URIs.
Learning map
🗺️ Learning Roadmap: Mastering MCP Resource Discovery and Reading
Phase 1: Foundational Knowledge
- Understand MCP (Model Context Protocol) core concepts — Resources, Tools, Prompts
- Understand Resource URI formats and classifications (file://, database://, custom protocols, etc.)
- Clarify the position of resource discovery within the Agent workflow
Phase 2: Environment Setup
- Install the MCP Python/TypeScript SDK
- Configure and start an MCP Server (example: filesystem server)
- Verify bidirectional Client ↔ Server connection status
Phase 3: Using ListMcpResourcesTool
- Call
list_resources()/resources/listmethod to retrieve the resource list - Use optional parameters to filter resources by server name
- Understand the return result structure (URI, MIME type, description, and other metadata)
Phase 4: In-Depth Practice
- Combine ReadMcpResourceTool to complete the full "discover → read" chain
- Handle pagination with cursors (cursor) to retrieve all resources
- Manage client connection pools in multi-Server scenarios
Phase 5: Advanced Exploration
- Write a custom MCP Server and expose ResourceTemplate
- Dynamically register mutable virtual resources (non-static files)
- Integrate resource browsing UI into Agent IDEs such as Claude Code / Cursor
Get hands-on — step by step
- Install the MCP SDK:
pip install mcpornpm install @modelcontextprotocol/sdk - Initialize an MCP Client and connect to the server:
from mcp import ClientSession session = await ClientSession() await session.connect( subprocess.Popen(["uvicorn", "my_server:app"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) ) - Call the resource list endpoint; omit parameters to fetch all:
resources = await session.list_resources() for r in resources: print(f"{r.uri} — {r.mimeType or 'text'}") - Filter by server name (if needed): Filter the
resourcesresult beforehand, or implement via a server filter on the Server side. - (Optional) Handle pagination: If the response includes
nextCursor, pass that cursor to calllist_resources(cursor=...)again until there are no more pages. - Combine with a read operation: Select a URI from the list and pass it to ReadMcpResourceTool:
content, mime_type = await session.read_resource("file:///path/to/file.txt") print(content) - Verify the end-to-end flow: Configure the MCP Server in Claude Code / Cursor and observe the complete call chain as the Agent automatically invokes resource discovery and reading.
- Explore custom servers: Create a new server that exposes a ResourceTemplate (dynamic URI prefix), restart the client, and repeat steps 3-6.
Top 3 sources
- 1MCP 官方规范 - Resources
MCP 协议 specification,详细描述 resources/list、资源 URI 格式及分页机制。
https://modelcontextprotocol.io/specification/2025-06-18/server/resources
- 2Anthropic MCP Python SDK 文档
MCP 官方 Python SDK,包含 list_resources()、read_resource() 等核心 API 的用法与示例。
https://github.com/modelcontextprotocol/python-sdk
- 3Phil Schmidt:MCP 入门指南
一篇清晰的 MCP 概览文章,解释了资源发现(Discovery)、上下文提供和 Agent 工作流中 MCP 的位置。
https://www.philschmid.de/mcp-introduction
Links are AI-suggested — worth a quick sanity check before diving in.