@@ -183,7 +183,7 @@ if __name__ == "__main__":
183183 mcp.run(transport = " streamable-http" )
184184```
185185
186- _ Full example: [ examples/snippets/servers/fastmcp_quickstart.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/fastmcp_quickstart.py ) _
186+ _ Full example: [ examples/snippets/servers/fastmcp_quickstart.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/fastmcp_quickstart.py ) _
187187<!-- /snippet-source -->
188188
189189You can install this server in [ Claude Code] ( https://docs.claude.com/en/docs/claude-code/mcp ) and interact with it right away. First, run the server:
@@ -282,7 +282,7 @@ def query_db(ctx: Context[ServerSession, AppContext]) -> str:
282282 return db.query()
283283```
284284
285- _ Full example: [ examples/snippets/servers/lifespan_example.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/lifespan_example.py ) _
285+ _ Full example: [ examples/snippets/servers/lifespan_example.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/lifespan_example.py ) _
286286<!-- /snippet-source -->
287287
288288### Resources
@@ -313,7 +313,7 @@ def get_settings() -> str:
313313}"""
314314```
315315
316- _ Full example: [ examples/snippets/servers/basic_resource.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/basic_resource.py ) _
316+ _ Full example: [ examples/snippets/servers/basic_resource.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/basic_resource.py ) _
317317<!-- /snippet-source -->
318318
319319### Tools
@@ -340,7 +340,7 @@ def get_weather(city: str, unit: str = "celsius") -> str:
340340 return f " Weather in { city} : 22degrees { unit[0 ].upper()} "
341341```
342342
343- _ Full example: [ examples/snippets/servers/basic_tool.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/basic_tool.py ) _
343+ _ Full example: [ examples/snippets/servers/basic_tool.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/basic_tool.py ) _
344344<!-- /snippet-source -->
345345
346346Tools can optionally receive a Context object by including a parameter with the ` Context ` type annotation. This context is automatically injected by the FastMCP framework and provides access to MCP capabilities:
@@ -370,7 +370,7 @@ async def long_running_task(task_name: str, ctx: Context[ServerSession, None], s
370370 return f " Task ' { task_name} ' completed "
371371```
372372
373- _ Full example: [ examples/snippets/servers/tool_progress.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/tool_progress.py ) _
373+ _ Full example: [ examples/snippets/servers/tool_progress.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/tool_progress.py ) _
374374<!-- /snippet-source -->
375375
376376#### Structured Output
@@ -455,7 +455,7 @@ def empty_result_tool() -> CallToolResult:
455455 return CallToolResult(content = [])
456456```
457457
458- _ Full example: [ examples/snippets/servers/direct_call_tool_result.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/direct_call_tool_result.py ) _
458+ _ Full example: [ examples/snippets/servers/direct_call_tool_result.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/direct_call_tool_result.py ) _
459459<!-- /snippet-source -->
460460
461461** Important:** ` CallToolResult ` must always be returned (no ` Optional ` or ` Union ` ). For empty results, use ` CallToolResult(content=[]) ` . For optional simple types, use ` str | None ` without ` CallToolResult ` .
@@ -561,7 +561,7 @@ def get_temperature(city: str) -> float:
561561 # Returns: {"result": 22.5}
562562```
563563
564- _ Full example: [ examples/snippets/servers/structured_output.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/structured_output.py ) _
564+ _ Full example: [ examples/snippets/servers/structured_output.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/structured_output.py ) _
565565<!-- /snippet-source -->
566566
567567### Prompts
@@ -590,7 +590,7 @@ def debug_error(error: str) -> list[base.Message]:
590590 ]
591591```
592592
593- _ Full example: [ examples/snippets/servers/basic_prompt.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/basic_prompt.py ) _
593+ _ Full example: [ examples/snippets/servers/basic_prompt.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/basic_prompt.py ) _
594594<!-- /snippet-source -->
595595
596596### Icons
@@ -626,7 +626,7 @@ def my_resource():
626626 return " content"
627627```
628628
629- _ Full example: [ examples/fastmcp/icons_demo.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/fastmcp/icons_demo.py ) _
629+ _ Full example: [ examples/fastmcp/icons_demo.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/fastmcp/icons_demo.py ) _
630630
631631### Images
632632
@@ -651,7 +651,7 @@ def create_thumbnail(image_path: str) -> Image:
651651 return Image(data = img.tobytes(), format = " png" )
652652```
653653
654- _ Full example: [ examples/snippets/servers/images.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/images.py ) _
654+ _ Full example: [ examples/snippets/servers/images.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/images.py ) _
655655<!-- /snippet-source -->
656656
657657### Context
@@ -718,7 +718,7 @@ async def long_running_task(task_name: str, ctx: Context[ServerSession, None], s
718718 return f " Task ' { task_name} ' completed "
719719```
720720
721- _ Full example: [ examples/snippets/servers/tool_progress.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/tool_progress.py ) _
721+ _ Full example: [ examples/snippets/servers/tool_progress.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/tool_progress.py ) _
722722<!-- /snippet-source -->
723723
724724### Completions
@@ -809,7 +809,7 @@ if __name__ == "__main__":
809809 main()
810810```
811811
812- _ Full example: [ examples/snippets/clients/completion_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/clients/completion_client.py ) _
812+ _ Full example: [ examples/snippets/clients/completion_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/clients/completion_client.py ) _
813813<!-- /snippet-source -->
814814### Elicitation
815815
@@ -918,7 +918,7 @@ async def connect_service(service_name: str, ctx: Context[ServerSession, None])
918918 )
919919```
920920
921- _ Full example: [ examples/snippets/servers/elicitation.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/elicitation.py ) _
921+ _ Full example: [ examples/snippets/servers/elicitation.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/elicitation.py ) _
922922<!-- /snippet-source -->
923923
924924Elicitation schemas support default values for all field types. Default values are automatically included in the JSON schema sent to clients, allowing them to pre-populate forms.
@@ -963,7 +963,7 @@ async def generate_poem(topic: str, ctx: Context[ServerSession, None]) -> str:
963963 return str (result.content)
964964```
965965
966- _ Full example: [ examples/snippets/servers/sampling.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/sampling.py ) _
966+ _ Full example: [ examples/snippets/servers/sampling.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/sampling.py ) _
967967<!-- /snippet-source -->
968968
969969### Logging and Notifications
@@ -993,7 +993,7 @@ async def process_data(data: str, ctx: Context[ServerSession, None]) -> str:
993993 return f " Processed: { data} "
994994```
995995
996- _ Full example: [ examples/snippets/servers/notifications.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/notifications.py ) _
996+ _ Full example: [ examples/snippets/servers/notifications.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/notifications.py ) _
997997<!-- /snippet-source -->
998998
999999### Authentication
@@ -1055,7 +1055,7 @@ if __name__ == "__main__":
10551055 mcp.run(transport = " streamable-http" )
10561056```
10571057
1058- _ Full example: [ examples/snippets/servers/oauth_server.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/oauth_server.py ) _
1058+ _ Full example: [ examples/snippets/servers/oauth_server.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/oauth_server.py ) _
10591059<!-- /snippet-source -->
10601060
10611061For a complete example with separate Authorization Server and Resource Server implementations, see [ ` examples/servers/simple-auth/ ` ] ( examples/servers/simple-auth/ ) .
@@ -1161,7 +1161,7 @@ def query_with_config(query: str, ctx: Context) -> str:
11611161 return str (result)
11621162```
11631163
1164- _ Full lifespan example: [ examples/snippets/servers/lifespan_example.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/lifespan_example.py ) _
1164+ _ Full lifespan example: [ examples/snippets/servers/lifespan_example.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/lifespan_example.py ) _
11651165
11661166## Running Your Server
11671167
@@ -1229,7 +1229,7 @@ if __name__ == "__main__":
12291229 main()
12301230```
12311231
1232- _ Full example: [ examples/snippets/servers/direct_execution.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/direct_execution.py ) _
1232+ _ Full example: [ examples/snippets/servers/direct_execution.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/direct_execution.py ) _
12331233<!-- /snippet-source -->
12341234
12351235Run it with:
@@ -1278,7 +1278,7 @@ if __name__ == "__main__":
12781278 mcp.run(transport = " streamable-http" )
12791279```
12801280
1281- _ Full example: [ examples/snippets/servers/streamable_config.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/streamable_config.py ) _
1281+ _ Full example: [ examples/snippets/servers/streamable_config.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/streamable_config.py ) _
12821282<!-- /snippet-source -->
12831283
12841284You can mount multiple FastMCP servers in a Starlette application:
@@ -1341,7 +1341,7 @@ app = Starlette(
13411341# math_mcp.settings.streamable_http_path = "/"
13421342```
13431343
1344- _ Full example: [ examples/snippets/servers/streamable_starlette_mount.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/streamable_starlette_mount.py ) _
1344+ _ Full example: [ examples/snippets/servers/streamable_starlette_mount.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/streamable_starlette_mount.py ) _
13451345<!-- /snippet-source -->
13461346
13471347For low level server with Streamable HTTP implementations, see:
@@ -1436,7 +1436,7 @@ app = Starlette(
14361436)
14371437```
14381438
1439- _ Full example: [ examples/snippets/servers/streamable_http_basic_mounting.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/streamable_http_basic_mounting.py ) _
1439+ _ Full example: [ examples/snippets/servers/streamable_http_basic_mounting.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/streamable_http_basic_mounting.py ) _
14401440<!-- /snippet-source -->
14411441
14421442##### Host-based routing
@@ -1483,7 +1483,7 @@ app = Starlette(
14831483)
14841484```
14851485
1486- _ Full example: [ examples/snippets/servers/streamable_http_host_mounting.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/streamable_http_host_mounting.py ) _
1486+ _ Full example: [ examples/snippets/servers/streamable_http_host_mounting.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/streamable_http_host_mounting.py ) _
14871487<!-- /snippet-source -->
14881488
14891489##### Multiple servers with path configuration
@@ -1546,7 +1546,7 @@ app = Starlette(
15461546)
15471547```
15481548
1549- _ Full example: [ examples/snippets/servers/streamable_http_multiple_servers.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/streamable_http_multiple_servers.py ) _
1549+ _ Full example: [ examples/snippets/servers/streamable_http_multiple_servers.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/streamable_http_multiple_servers.py ) _
15501550<!-- /snippet-source -->
15511551
15521552##### Path configuration at initialization
@@ -1588,7 +1588,7 @@ app = Starlette(
15881588)
15891589```
15901590
1591- _ Full example: [ examples/snippets/servers/streamable_http_path_config.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/streamable_http_path_config.py ) _
1591+ _ Full example: [ examples/snippets/servers/streamable_http_path_config.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/streamable_http_path_config.py ) _
15921592<!-- /snippet-source -->
15931593
15941594#### SSE servers
@@ -1769,7 +1769,7 @@ if __name__ == "__main__":
17691769 asyncio.run(run())
17701770```
17711771
1772- _ Full example: [ examples/snippets/servers/lowlevel/lifespan.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/lowlevel/lifespan.py ) _
1772+ _ Full example: [ examples/snippets/servers/lowlevel/lifespan.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/lowlevel/lifespan.py ) _
17731773<!-- /snippet-source -->
17741774
17751775The lifespan API provides:
@@ -1848,7 +1848,7 @@ if __name__ == "__main__":
18481848 asyncio.run(run())
18491849```
18501850
1851- _ Full example: [ examples/snippets/servers/lowlevel/basic.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/lowlevel/basic.py ) _
1851+ _ Full example: [ examples/snippets/servers/lowlevel/basic.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/lowlevel/basic.py ) _
18521852<!-- /snippet-source -->
18531853
18541854Caution: The ` uv run mcp run ` and ` uv run mcp dev ` tool doesn't support low-level server.
@@ -1944,7 +1944,7 @@ if __name__ == "__main__":
19441944 asyncio.run(run())
19451945```
19461946
1947- _ Full example: [ examples/snippets/servers/lowlevel/structured_output.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/lowlevel/structured_output.py ) _
1947+ _ Full example: [ examples/snippets/servers/lowlevel/structured_output.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/lowlevel/structured_output.py ) _
19481948<!-- /snippet-source -->
19491949
19501950Tools can return data in four ways:
@@ -2029,7 +2029,7 @@ if __name__ == "__main__":
20292029 asyncio.run(run())
20302030```
20312031
2032- _ Full example: [ examples/snippets/servers/lowlevel/direct_call_tool_result.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/lowlevel/direct_call_tool_result.py ) _
2032+ _ Full example: [ examples/snippets/servers/lowlevel/direct_call_tool_result.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/lowlevel/direct_call_tool_result.py ) _
20332033<!-- /snippet-source -->
20342034
20352035** Note:** When returning ` CallToolResult ` , you bypass the automatic content/structured conversion. You must construct the complete response yourself.
@@ -2082,7 +2082,7 @@ async def list_resources_paginated(request: types.ListResourcesRequest) -> types
20822082 return types.ListResourcesResult(resources = page_items, nextCursor = next_cursor)
20832083```
20842084
2085- _ Full example: [ examples/snippets/servers/pagination_example.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/servers/pagination_example.py ) _
2085+ _ Full example: [ examples/snippets/servers/pagination_example.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/servers/pagination_example.py ) _
20862086<!-- /snippet-source -->
20872087
20882088#### Client-side Consumption
@@ -2132,7 +2132,7 @@ if __name__ == "__main__":
21322132 asyncio.run(list_all_resources())
21332133```
21342134
2135- _ Full example: [ examples/snippets/clients/pagination_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/clients/pagination_client.py ) _
2135+ _ Full example: [ examples/snippets/clients/pagination_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/clients/pagination_client.py ) _
21362136<!-- /snippet-source -->
21372137
21382138#### Key Points
@@ -2235,7 +2235,7 @@ if __name__ == "__main__":
22352235 main()
22362236```
22372237
2238- _ Full example: [ examples/snippets/clients/stdio_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/clients/stdio_client.py ) _
2238+ _ Full example: [ examples/snippets/clients/stdio_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/clients/stdio_client.py ) _
22392239<!-- /snippet-source -->
22402240
22412241Clients can also connect using [ Streamable HTTP transport] ( https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http ) :
@@ -2273,7 +2273,7 @@ if __name__ == "__main__":
22732273 asyncio.run(main())
22742274```
22752275
2276- _ Full example: [ examples/snippets/clients/streamable_basic.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/clients/streamable_basic.py ) _
2276+ _ Full example: [ examples/snippets/clients/streamable_basic.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/clients/streamable_basic.py ) _
22772277<!-- /snippet-source -->
22782278
22792279### Client Display Utilities
@@ -2351,7 +2351,7 @@ if __name__ == "__main__":
23512351 main()
23522352```
23532353
2354- _ Full example: [ examples/snippets/clients/display_utilities.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/clients/display_utilities.py ) _
2354+ _ Full example: [ examples/snippets/clients/display_utilities.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/clients/display_utilities.py ) _
23552355<!-- /snippet-source -->
23562356
23572357The ` get_display_name() ` function implements the proper precedence rules for displaying names:
@@ -2458,7 +2458,7 @@ if __name__ == "__main__":
24582458 run()
24592459```
24602460
2461- _ Full example: [ examples/snippets/clients/oauth_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/main /examples/snippets/clients/oauth_client.py ) _
2461+ _ Full example: [ examples/snippets/clients/oauth_client.py] ( https://github.com/modelcontextprotocol/python-sdk/blob/v1.x /examples/snippets/clients/oauth_client.py ) _
24622462<!-- /snippet-source -->
24632463
24642464For a complete working example, see [ ` examples/clients/simple-auth-client/ ` ] ( examples/clients/simple-auth-client/ ) .
0 commit comments