Jeremiah Lowin commited on
Commit
776a75d
·
1 Parent(s): ceea07c

Update resources.mdx

Browse files
Files changed (1) hide show
  1. docs/servers/resources.mdx +8 -1
docs/servers/resources.mdx CHANGED
@@ -251,13 +251,18 @@ With these two templates defined, clients can request a variety of resources:
251
 
252
  <VersionBadge version="2.2.3" />
253
 
 
 
 
 
254
  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.
255
 
256
- ```python
257
  from fastmcp import FastMCP
258
 
259
  mcp = FastMCP(name="DataServer")
260
 
 
261
  # Standard parameter only matches one segment
262
  @mcp.resource("files://{filename}")
263
  def get_file(filename: str) -> str:
@@ -265,6 +270,7 @@ def get_file(filename: str) -> str:
265
  # Will only match files://<single-segment>
266
  return f"File content for: {filename}"
267
 
 
268
  # Wildcard parameter can match multiple segments
269
  @mcp.resource("path://{filepath*}")
270
  def get_path_content(filepath: str) -> str:
@@ -272,6 +278,7 @@ def get_path_content(filepath: str) -> str:
272
  # Can match path://docs/server/resources.mdx
273
  return f"Content at path: {filepath}"
274
 
 
275
  # Mixing standard and wildcard parameters
276
  @mcp.resource("repo://{owner}/{path*}/template.py")
277
  def get_template_file(owner: str, path: str) -> dict:
 
251
 
252
  <VersionBadge version="2.2.3" />
253
 
254
+ <Warning>
255
+ 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.
256
+ </Warning>
257
+
258
  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.
259
 
260
+ ```python {15, 23}
261
  from fastmcp import FastMCP
262
 
263
  mcp = FastMCP(name="DataServer")
264
 
265
+
266
  # Standard parameter only matches one segment
267
  @mcp.resource("files://{filename}")
268
  def get_file(filename: str) -> str:
 
270
  # Will only match files://<single-segment>
271
  return f"File content for: {filename}"
272
 
273
+
274
  # Wildcard parameter can match multiple segments
275
  @mcp.resource("path://{filepath*}")
276
  def get_path_content(filepath: str) -> str:
 
278
  # Can match path://docs/server/resources.mdx
279
  return f"Content at path: {filepath}"
280
 
281
+
282
  # Mixing standard and wildcard parameters
283
  @mcp.resource("repo://{owner}/{path*}/template.py")
284
  def get_template_file(owner: str, path: str) -> dict: