From efec36f45d83c0f91cf5f1fc9fec47fee1ee9710 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Tue, 15 Apr 2025 01:23:28 -0400 Subject: [PATCH] Update resources.mdx --- docs/servers/resources.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/servers/resources.mdx b/docs/servers/resources.mdx index c9363b7aa..ec8d031d5 100644 --- a/docs/servers/resources.mdx +++ b/docs/servers/resources.mdx @@ -228,6 +228,10 @@ However, function parameters with default values don't need to be included in th This allows for flexible API designs. For example, a simple search template with optional parameters: ```python +from fastmcp import FastMCP + +mcp = FastMCP(name="DataServer") + @mcp.resource("search://{query}") def search_resources(query: str, max_results: int = 10, include_archived: bool = False) -> dict: """Search for resources matching the query string.""" @@ -246,6 +250,10 @@ With this template, clients can request `search://python` and the function will An even more powerful pattern is registering a single function with multiple URI templates, allowing different ways to access the same data: ```python +from fastmcp import FastMCP + +mcp = FastMCP(name="DataServer") + # Define a user lookup function that can be accessed by different identifiers @mcp.resource("users://email/{email}") @mcp.resource("users://name/{name}")