Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
9047253
1
Parent(s): dcec329
Update resources.mdx
Browse files
docs/servers/resources.mdx
CHANGED
|
@@ -228,6 +228,10 @@ However, function parameters with default values don't need to be included in th
|
|
| 228 |
This allows for flexible API designs. For example, a simple search template with optional parameters:
|
| 229 |
|
| 230 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
@mcp.resource("search://{query}")
|
| 232 |
def search_resources(query: str, max_results: int = 10, include_archived: bool = False) -> dict:
|
| 233 |
"""Search for resources matching the query string."""
|
|
@@ -246,6 +250,10 @@ With this template, clients can request `search://python` and the function will
|
|
| 246 |
An even more powerful pattern is registering a single function with multiple URI templates, allowing different ways to access the same data:
|
| 247 |
|
| 248 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
# Define a user lookup function that can be accessed by different identifiers
|
| 250 |
@mcp.resource("users://email/{email}")
|
| 251 |
@mcp.resource("users://name/{name}")
|
|
|
|
| 228 |
This allows for flexible API designs. For example, a simple search template with optional parameters:
|
| 229 |
|
| 230 |
```python
|
| 231 |
+
from fastmcp import FastMCP
|
| 232 |
+
|
| 233 |
+
mcp = FastMCP(name="DataServer")
|
| 234 |
+
|
| 235 |
@mcp.resource("search://{query}")
|
| 236 |
def search_resources(query: str, max_results: int = 10, include_archived: bool = False) -> dict:
|
| 237 |
"""Search for resources matching the query string."""
|
|
|
|
| 250 |
An even more powerful pattern is registering a single function with multiple URI templates, allowing different ways to access the same data:
|
| 251 |
|
| 252 |
```python
|
| 253 |
+
from fastmcp import FastMCP
|
| 254 |
+
|
| 255 |
+
mcp = FastMCP(name="DataServer")
|
| 256 |
+
|
| 257 |
# Define a user lookup function that can be accessed by different identifiers
|
| 258 |
@mcp.resource("users://email/{email}")
|
| 259 |
@mcp.resource("users://name/{name}")
|