π The fast, Pythonic way to build MCP servers and clients.
Remove stale add_resource() key parameter from docs (#3309)
Jeremiah Lowinc349bd9e256a
diff --git a/docs/servers/resources.mdx b/docs/servers/resources.mdxindex 79510db69..0a8a772aa 100644--- a/docs/servers/resources.mdx+++ b/docs/servers/resources.mdx@@ -332,15 +332,7 @@ notice_resource = TextResource()mcp.add_resource(notice_resource)-# 3. Using a custom key different from the URI-special_resource = TextResource(- uri="resource://common-notice",- name="Special Notice",- text="This is a special notice with a custom storage key.",-)-mcp.add_resource(special_resource, key="resource://custom-key")--# 4. Exposing a directory listing+# 3. Exposing a directory listingdata_dir_path = Path("./app_data").resolve()if data_dir_path.is_dir():data_listing_resource = DirectoryResource(@@ -364,24 +356,6 @@ if data_dir_path.is_dir():Use these when the content is static or sourced directly from a file/URL, bypassing the need for a dedicated Python function.-#### Custom Resource Keys--<VersionBadge version="2.2.0" />--When adding resources directly with `mcp.add_resource()`, you can optionally provide a custom storage key:--```python-# Creating a resource with standard URI as the key-resource = TextResource(uri="resource://data")-mcp.add_resource(resource) # Will be stored and accessed using "resource://data"--# Creating a resource with a custom key-special_resource = TextResource(uri="resource://special-data")-mcp.add_resource(special_resource, key="internal://data-v2") # Will be stored and accessed using "internal://data-v2"-```--Note that this parameter is only available when using `add_resource()` directly and not through the `@resource` decorator, as URIs are provided explicitly when using the decorator.-### Notifications<VersionBadge version="2.9.1" />diff --git a/docs/v2/servers/resources.mdx b/docs/v2/servers/resources.mdxindex 3cba5e071..a76734f12 100644--- a/docs/v2/servers/resources.mdx+++ b/docs/v2/servers/resources.mdx@@ -254,15 +254,7 @@ notice_resource = TextResource()mcp.add_resource(notice_resource)-# 3. Using a custom key different from the URI-special_resource = TextResource(- uri="resource://common-notice",- name="Special Notice",- text="This is a special notice with a custom storage key.",-)-mcp.add_resource(special_resource, key="resource://custom-key")--# 4. Exposing a directory listing+# 3. Exposing a directory listingdata_dir_path = Path("./app_data").resolve()if data_dir_path.is_dir():data_listing_resource = DirectoryResource(@@ -286,24 +278,6 @@ if data_dir_path.is_dir():Use these when the content is static or sourced directly from a file/URL, bypassing the need for a dedicated Python function.-#### Custom Resource Keys--<VersionBadge version="2.2.0" />--When adding resources directly with `mcp.add_resource()`, you can optionally provide a custom storage key:--```python-# Creating a resource with standard URI as the key-resource = TextResource(uri="resource://data")-mcp.add_resource(resource) # Will be stored and accessed using "resource://data"--# Creating a resource with a custom key-special_resource = TextResource(uri="resource://special-data")-mcp.add_resource(special_resource, key="internal://data-v2") # Will be stored and accessed using "internal://data-v2"-```--Note that this parameter is only available when using `add_resource()` directly and not through the `@resource` decorator, as URIs are provided explicitly when using the decorator.-### Notifications<VersionBadge version="2.9.1" />