🚀 The fast, Pythonic way to build MCP servers and clients.
docs: fix stale get_* references, now list_* (#3168)
Jeremiah Lowin3907a4f9b6ec
diff --git a/docs/development/upgrade-guide.mdx b/docs/development/upgrade-guide.mdxindex 8bfe713af..f8f63c66a 100644--- a/docs/development/upgrade-guide.mdx+++ b/docs/development/upgrade-guide.mdx@@ -43,9 +43,9 @@ tool.disable()server.disable(names={"my_tool"}, components=["tool"])```-#### Listing Methods Return Lists+#### Listing Methods Renamed and Return Lists-`get_tools()`, `get_resources()`, `get_prompts()`, and `get_resource_templates()` now return lists instead of dicts:+`get_tools()`, `get_resources()`, `get_prompts()`, and `get_resource_templates()` have been replaced by `list_tools()`, `list_resources()`, `list_prompts()`, and `list_resource_templates()`. The new methods return lists instead of dicts:```python# Before@@ -53,7 +53,7 @@ tools = await server.get_tools()tool = tools["my_tool"]# After-tools = await server.get_tools()+tools = await server.list_tools()tool = next((t for t in tools if t.name == "my_tool"), None)```diff --git a/docs/development/v3-notes/v3-features.mdx b/docs/development/v3-notes/v3-features.mdxindex aca82b92a..ae6bfc27d 100644--- a/docs/development/v3-notes/v3-features.mdx+++ b/docs/development/v3-notes/v3-features.mdx@@ -1376,7 +1376,8 @@ server.disable(names={"my_tool"}, components=["tool"])Server lookup and listing methods have updated signatures:- Parameter names: `get_tool(name=...)`, `get_resource(uri=...)`, etc. (was `key`)-- Return types: `get_tools()`, `get_resources()`, etc. return lists instead of dicts+- Plural listing methods renamed: `get_tools()` → `list_tools()`, `get_resources()` → `list_resources()`, etc.+- Return types: `list_tools()`, `list_resources()`, etc. return lists instead of dicts```python# v2.x@@ -1384,7 +1385,7 @@ tools = await server.get_tools()tool = tools["my_tool"]# v3.0-tools = await server.get_tools()+tools = await server.list_tools()tool = next((t for t in tools if t.name == "my_tool"), None)```diff --git a/examples/mount_example.py b/examples/mount_example.pyindex 228c90f29..9e8c0fb42 100644--- a/examples/mount_example.py+++ b/examples/mount_example.py@@ -71,9 +71,9 @@ app.mount(server=news_app, prefix="news")async def get_server_details():"""Print information about mounted resources."""# Print available tools- tools = await app.get_tools()+ tools = await app.list_tools()print(f"\nAvailable tools ({len(tools)}):")- for _, tool in tools.items():+ for tool in tools:print(f" - {tool.name}: {tool.description}")# Print available resources@@ -82,20 +82,20 @@ async def get_server_details():# Distinguish between native and imported resources# Native resources would be those directly in the main app (not prefixed)- resources = await app.get_resources()+ resources = await app.list_resources()native_resources = [- uri- for uri, _ in resources.items()- if urlparse(uri).netloc not in ("weather", "news")+ str(r.uri)+ for r in resources+ if urlparse(str(r.uri)).netloc not in ("weather", "news")]# Imported resources - categorized by source appweather_resources = [- uri for uri, _ in resources.items() if urlparse(uri).netloc == "weather"+ str(r.uri) for r in resources if urlparse(str(r.uri)).netloc == "weather"]news_resources = [- uri for uri, _ in resources.items() if urlparse(uri).netloc == "news"+ str(r.uri) for r in resources if urlparse(str(r.uri)).netloc == "news"]print(f" - Native app resources: {native_resources}")diff --git a/examples/tags_example.py b/examples/tags_example.pyindex fa79a60df..c5ff6ae0e 100644--- a/examples/tags_example.py+++ b/examples/tags_example.py@@ -60,11 +60,11 @@ async def main():],)- tools = await mcp1.get_tools()- resources = await mcp1.get_resources()+ tools = await mcp1.list_tools()+ resources = await mcp1.list_resources()- print(f"Tools ({len(tools)}): {', '.join(tools.keys())}")- print(f"Resources ({len(resources)}): {', '.join(resources.keys())}")+ print(f"Tools ({len(tools)}): {', '.join(t.name for t in tools)}")+ print(f"Resources ({len(resources)}): {', '.join(str(r.uri) for r in resources)}")print("\n=== Example 2: Exclude internal routes ===")@@ -80,11 +80,11 @@ async def main():],)- tools = await mcp2.get_tools()- resources = await mcp2.get_resources()+ tools = await mcp2.list_tools()+ resources = await mcp2.list_resources()- print(f"Tools ({len(tools)}): {', '.join(tools.keys())}")- print(f"Resources ({len(resources)}): {', '.join(resources.keys())}")+ print(f"Tools ({len(tools)}): {', '.join(t.name for t in tools)}")+ print(f"Resources ({len(resources)}): {', '.join(str(r.uri) for r in resources)}")print("\n=== Example 3: Pattern + Tags combination ===")@@ -107,11 +107,11 @@ async def main():],)- tools = await mcp3.get_tools()- resources = await mcp3.get_resources()+ tools = await mcp3.list_tools()+ resources = await mcp3.list_resources()- print(f"Tools ({len(tools)}): {', '.join(tools.keys())}")- print(f"Resources ({len(resources)}): {', '.join(resources.keys())}")+ print(f"Tools ({len(tools)}): {', '.join(t.name for t in tools)}")+ print(f"Resources ({len(resources)}): {', '.join(str(r.uri) for r in resources)}")print("\n=== Example 4: Multiple tag AND condition ===")@@ -130,11 +130,11 @@ async def main():],)- tools = await mcp4.get_tools()- resources = await mcp4.get_resources()+ tools = await mcp4.list_tools()+ resources = await mcp4.list_resources()- print(f"Tools ({len(tools)}): {', '.join(tools.keys())}")- print(f"Resources ({len(resources)}): {', '.join(resources.keys())}")+ print(f"Tools ({len(tools)}): {', '.join(t.name for t in tools)}")+ print(f"Resources ({len(resources)}): {', '.join(str(r.uri) for r in resources)}")if __name__ == "__main__":diff --git a/v3-notes/get-methods-consolidation.md b/v3-notes/get-methods-consolidation.mdindex 6a67487e4..70b64c9c7 100644--- a/v3-notes/get-methods-consolidation.md+++ b/v3-notes/get-methods-consolidation.md@@ -1,6 +1,6 @@-# Consolidating get_* and _list_* Methods+# Consolidating Discovery Methods-This document captures the design decision to consolidate component listing methods in FastMCP 3.0.+This document captures the design decisions around component listing methods in FastMCP 3.0.## Problem@@ -14,20 +14,16 @@ These were nearly identical but with subtle differences in dedup keys, logging,## Solution-`get_*` is now the canonical method. The `_list_*` methods were deleted entirely.+The duplicate methods were consolidated into a single set of `list_*` methods. The old `get_*` plural methods and `_list_*` internal methods were both removed.++This happened in two phases:++1. **Consolidation** (Dec 2025): Merged `get_*` and `_list_*` into a single `get_*` method with an `apply_middleware` parameter.+2. **Rename** (Jan 2026): When `FastMCP` was refactored to inherit from `Provider`, the methods were renamed to `list_*` to align with the `Provider` interface. The `apply_middleware` parameter was renamed to `run_middleware` with a default of `True`.```python-async def get_tools(self, *, apply_middleware: bool = False) -> list[Tool]:+async def list_tools(self, *, run_middleware: bool = True) -> Sequence[Tool]:"""Canonical method for listing tools."""- if apply_middleware:- # Apply middleware chain (for MCP protocol handlers)- mw_context = MiddlewareContext(...)- return await self._apply_middleware(- context=mw_context,- call_next=lambda context: self.get_tools(apply_middleware=False)- )-- # Core implementation: query providers, dedupe, filter visibility...```@@ -38,32 +34,28 @@ async def get_tools(self, *, apply_middleware: bool = False) -> list[Tool]:The dict return type was removed because the key was redundant—components already have `.name` or `.uri` attributes.```python-# Before+# Before (v2.x)tools = await server.get_tools()tool = tools["my_tool"]-# After-tools = await server.get_tools()+# After (v3.0)+tools = await server.list_tools()tool = next(t for t in tools if t.name == "my_tool")```### Middleware via Parameter-The `apply_middleware=True` parameter applies the middleware chain. This replaces the separate `_list_*_middleware()` methods.--Callers:-- MCP protocol handlers: `get_tools(apply_middleware=True)`-- Direct access: `get_tools()` (default False)+The `run_middleware=True` parameter (default) applies the middleware chain. This replaces the separate `_list_*_middleware()` methods.## Benefits1. **Single source of truth** - One method, not two2. **Consistent behavior** - Same dedup key, same visibility filtering3. **Clearer API** - Public method with explicit middleware opt-in-4. **Less code** - Deleted ~200 lines of duplicate implementation+4. **Provider alignment** - `FastMCP.list_tools()` overrides `Provider.list_tools()`+5. **Less code** - Deleted ~200 lines of duplicate implementation## Implementation Files-- `src/fastmcp/server/server.py` - Canonical `get_*` methods-- `src/fastmcp/server/providers/fastmcp_provider.py` - Uses `apply_middleware=True`-- `src/fastmcp/utilities/inspect.py` - Uses `apply_middleware=True`+- `src/fastmcp/server/server.py` - Canonical `list_*` methods+- `src/fastmcp/server/providers/` - Provider base class defines the interface