@@ -235,6 +235,7 @@ def get_settings() -> str:
235
235
"debug": false
236
236
}"""
237
237
```
238
+
238
239
_ Full example: [ examples/snippets/servers/basic_resource.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/basic_resource.py ) _
239
240
<!-- /snippet-source -->
240
241
@@ -261,6 +262,7 @@ def get_weather(city: str, unit: str = "celsius") -> str:
261
262
# This would normally call a weather API
262
263
return f " Weather in { city} : 22degrees { unit[0 ].upper()} "
263
264
```
265
+
264
266
_ Full example: [ examples/snippets/servers/basic_tool.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/basic_tool.py ) _
265
267
<!-- /snippet-source -->
266
268
@@ -411,6 +413,7 @@ def debug_error(error: str) -> list[base.Message]:
411
413
base.AssistantMessage(" I'll help debug that. What have you tried so far?" ),
412
414
]
413
415
```
416
+
414
417
_ Full example: [ examples/snippets/servers/basic_prompt.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/basic_prompt.py ) _
415
418
<!-- /snippet-source -->
416
419
@@ -460,6 +463,7 @@ async def long_running_task(task_name: str, ctx: Context, steps: int = 5) -> str
460
463
461
464
return f " Task ' { task_name} ' completed "
462
465
```
466
+
463
467
_ Full example: [ examples/snippets/servers/tool_progress.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/tool_progress.py ) _
464
468
<!-- /snippet-source -->
465
469
@@ -547,6 +551,7 @@ async def handle_completion(
547
551
548
552
return None
549
553
```
554
+
550
555
_ Full example: [ examples/snippets/servers/completion.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/completion.py ) _
551
556
<!-- /snippet-source -->
552
557
### Elicitation
@@ -597,6 +602,7 @@ async def book_table(
597
602
# Date available
598
603
return f " [SUCCESS] Booked for { date} at { time} "
599
604
```
605
+
600
606
_ Full example: [ examples/snippets/servers/elicitation.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/elicitation.py ) _
601
607
<!-- /snippet-source -->
602
608
@@ -637,6 +643,7 @@ async def generate_poem(topic: str, ctx: Context) -> str:
637
643
return result.content.text
638
644
return str (result.content)
639
645
```
646
+
640
647
_ Full example: [ examples/snippets/servers/sampling.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/sampling.py ) _
641
648
<!-- /snippet-source -->
642
649
@@ -665,6 +672,7 @@ async def process_data(data: str, ctx: Context) -> str:
665
672
666
673
return f " Processed: { data} "
667
674
```
675
+
668
676
_ Full example: [ examples/snippets/servers/notifications.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/notifications.py ) _
669
677
<!-- /snippet-source -->
670
678
0 commit comments