feat: RFC 6570 URI templates with operator-aware security (#2356)
This commit is contained in:
parent
067f90578c
commit
24717cc8eb
1 changed files with 3800 additions and 37 deletions
14
docs_src/uri_templates/tutorial002.py
Normal file
14
docs_src/uri_templates/tutorial002.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from pathlib import Path
|
||||
|
||||
from mcp.server import MCPServer
|
||||
from mcp.shared.path_security import safe_join
|
||||
|
||||
mcp = MCPServer("Bookshop")
|
||||
|
||||
DOCS_ROOT = Path("./manuals")
|
||||
|
||||
|
||||
@mcp.resource("manuals://{+path}")
|
||||
def read_manual(path: str) -> str:
|
||||
"""A staff manual page, served from a directory on disk."""
|
||||
return safe_join(DOCS_ROOT, path).read_text()
|
||||
Loading…
Reference in a new issue