mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Update resources.mdx
This commit is contained in:
parent
713864aa9a
commit
4e650dedf5
1 changed files with 8 additions and 1 deletions
|
|
@ -251,13 +251,18 @@ With these two templates defined, clients can request a variety of resources:
|
|||
|
||||
<VersionBadge version="2.2.3" />
|
||||
|
||||
<Warning>
|
||||
Please note: the Model Context Protocol URI standard follows RFC 6570, which does not include support for wildcard parameters. FastMCP extends the template syntax to support wildcards (`{param*}`), and because template matching happens entirely in the FastMCP server, it is not expected that these wildcards will cause compatibility issues with other MCP implementations. However, this can not be guaranteed.
|
||||
</Warning>
|
||||
|
||||
Resource templates support wildcard parameters that can match multiple path segments. While standard parameters (`{param}`) only match a single path segment and don't cross "/" boundaries, wildcard parameters (`{param*}`) can capture multiple segments including slashes. Wildcards capture all subsequent path segments *up until* the defined part of the URI template (whether literal or another parameter). This allows you to have multiple wildcard parameters in a single URI template.
|
||||
|
||||
```python
|
||||
```python {15, 23}
|
||||
from fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP(name="DataServer")
|
||||
|
||||
|
||||
# Standard parameter only matches one segment
|
||||
@mcp.resource("files://{filename}")
|
||||
def get_file(filename: str) -> str:
|
||||
|
|
@ -265,6 +270,7 @@ def get_file(filename: str) -> str:
|
|||
# Will only match files://<single-segment>
|
||||
return f"File content for: {filename}"
|
||||
|
||||
|
||||
# Wildcard parameter can match multiple segments
|
||||
@mcp.resource("path://{filepath*}")
|
||||
def get_path_content(filepath: str) -> str:
|
||||
|
|
@ -272,6 +278,7 @@ def get_path_content(filepath: str) -> str:
|
|||
# Can match path://docs/server/resources.mdx
|
||||
return f"Content at path: {filepath}"
|
||||
|
||||
|
||||
# Mixing standard and wildcard parameters
|
||||
@mcp.resource("repo://{owner}/{path*}/template.py")
|
||||
def get_template_file(owner: str, path: str) -> dict:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue