Embed code snippets for README from executable examples (#1055)
This commit is contained in:
parent
7bc190bae8
commit
adf327164a
1 changed files with 1139 additions and 1131 deletions
20
examples/snippets/servers/basic_resource.py
Normal file
20
examples/snippets/servers/basic_resource.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP(name="Resource Example")
|
||||
|
||||
|
||||
@mcp.resource("file://documents/{name}")
|
||||
def read_document(name: str) -> str:
|
||||
"""Read a document by name."""
|
||||
# This would normally read from disk
|
||||
return f"Content of {name}"
|
||||
|
||||
|
||||
@mcp.resource("config://settings")
|
||||
def get_settings() -> str:
|
||||
"""Get application settings."""
|
||||
return """{
|
||||
"theme": "dark",
|
||||
"language": "en",
|
||||
"debug": false
|
||||
}"""
|
||||
Loading…
Reference in a new issue