mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-20 20:44:17 +02:00
Update resources.mdx
This commit is contained in:
parent
45f4030183
commit
efec36f45d
1 changed files with 8 additions and 0 deletions
|
|
@ -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}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue