From c349bd9e256a6b0443c6db60e5533cba6c348cc4 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:10:02 -0500 Subject: [PATCH] Remove stale add_resource() key parameter from docs (#3309) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `key` parameter was removed from `add_resource()` in the 2.x era and no longer exists in the implementation. Removes all references and the "Custom Resource Keys" section from both the current and v2 docs. 🤖 Generated with Claude Code https://claude.ai/code/session_01Nc1qEJ1rKaRRxB5h6Qu5V3 Co-authored-by: Claude --- docs/servers/resources.mdx | 28 +--------------------------- docs/v2/servers/resources.mdx | 28 +--------------------------- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/docs/servers/resources.mdx b/docs/servers/resources.mdx index 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 listing data_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 - - - -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 diff --git a/docs/v2/servers/resources.mdx b/docs/v2/servers/resources.mdx index 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 listing data_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 - - - -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