Skip to content

Commit 3954642

Browse files
docs: update README snippets with new docstring format
1 parent cc533af commit 3954642

File tree

1 file changed

+29
-50
lines changed

1 file changed

+29
-50
lines changed

README.md

Lines changed: 29 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ Let's create a simple MCP server that exposes a calculator tool and some data:
136136

137137
<!-- snippet-source examples/snippets/servers/fastmcp_quickstart.py -->
138138
```python
139-
"""
140-
FastMCP quickstart example.
139+
"""FastMCP quickstart example.
141140
142141
Run from the repository root:
143142
uv run examples/snippets/servers/fastmcp_quickstart.py
@@ -727,9 +726,8 @@ Client usage:
727726

728727
<!-- snippet-source examples/snippets/clients/completion_client.py -->
729728
```python
730-
"""
731-
cd to the `examples/snippets` directory and run:
732-
uv run completion-client
729+
"""cd to the `examples/snippets` directory and run:
730+
uv run completion-client
733731
"""
734732

735733
import asyncio
@@ -1004,9 +1002,8 @@ MCP servers can use authentication by providing an implementation of the `TokenV
10041002

10051003
<!-- snippet-source examples/snippets/servers/oauth_server.py -->
10061004
```python
1007-
"""
1008-
Run from the repository root:
1009-
uv run examples/snippets/servers/oauth_server.py
1005+
"""Run from the repository root:
1006+
uv run examples/snippets/servers/oauth_server.py
10101007
"""
10111008

10121009
from pydantic import AnyHttpUrl
@@ -1245,9 +1242,8 @@ Note that `uv run mcp run` or `uv run mcp dev` only supports server using FastMC
12451242
12461243
<!-- snippet-source examples/snippets/servers/streamable_config.py -->
12471244
```python
1248-
"""
1249-
Run from the repository root:
1250-
uv run examples/snippets/servers/streamable_config.py
1245+
"""Run from the repository root:
1246+
uv run examples/snippets/servers/streamable_config.py
12511247
"""
12521248

12531249
from mcp.server.fastmcp import FastMCP
@@ -1283,9 +1279,8 @@ You can mount multiple FastMCP servers in a Starlette application:
12831279

12841280
<!-- snippet-source examples/snippets/servers/streamable_starlette_mount.py -->
12851281
```python
1286-
"""
1287-
Run from the repository root:
1288-
uvicorn examples.snippets.servers.streamable_starlette_mount:app --reload
1282+
"""Run from the repository root:
1283+
uvicorn examples.snippets.servers.streamable_starlette_mount:app --reload
12891284
"""
12901285

12911286
import contextlib
@@ -1394,8 +1389,7 @@ You can mount the StreamableHTTP server to an existing ASGI server using the `st
13941389

13951390
<!-- snippet-source examples/snippets/servers/streamable_http_basic_mounting.py -->
13961391
```python
1397-
"""
1398-
Basic example showing how to mount StreamableHTTP server in Starlette.
1392+
"""Basic example showing how to mount StreamableHTTP server in Starlette.
13991393
14001394
Run from the repository root:
14011395
uvicorn examples.snippets.servers.streamable_http_basic_mounting:app --reload
@@ -1442,8 +1436,7 @@ _Full example: [examples/snippets/servers/streamable_http_basic_mounting.py](htt
14421436

14431437
<!-- snippet-source examples/snippets/servers/streamable_http_host_mounting.py -->
14441438
```python
1445-
"""
1446-
Example showing how to mount StreamableHTTP server using Host-based routing.
1439+
"""Example showing how to mount StreamableHTTP server using Host-based routing.
14471440
14481441
Run from the repository root:
14491442
uvicorn examples.snippets.servers.streamable_http_host_mounting:app --reload
@@ -1490,8 +1483,7 @@ _Full example: [examples/snippets/servers/streamable_http_host_mounting.py](http
14901483

14911484
<!-- snippet-source examples/snippets/servers/streamable_http_multiple_servers.py -->
14921485
```python
1493-
"""
1494-
Example showing how to mount multiple StreamableHTTP servers with path configuration.
1486+
"""Example showing how to mount multiple StreamableHTTP servers with path configuration.
14951487
14961488
Run from the repository root:
14971489
uvicorn examples.snippets.servers.streamable_http_multiple_servers:app --reload
@@ -1548,8 +1540,7 @@ _Full example: [examples/snippets/servers/streamable_http_multiple_servers.py](h
15481540

15491541
<!-- snippet-source examples/snippets/servers/streamable_http_path_config.py -->
15501542
```python
1551-
"""
1552-
Example showing path configuration when mounting FastMCP.
1543+
"""Example showing path configuration when mounting FastMCP.
15531544
15541545
Run from the repository root:
15551546
uvicorn examples.snippets.servers.streamable_http_path_config:app --reload
@@ -1644,9 +1635,8 @@ For more control, you can use the low-level server implementation directly. This
16441635

16451636
<!-- snippet-source examples/snippets/servers/lowlevel/lifespan.py -->
16461637
```python
1647-
"""
1648-
Run from the repository root:
1649-
uv run examples/snippets/servers/lowlevel/lifespan.py
1638+
"""Run from the repository root:
1639+
uv run examples/snippets/servers/lowlevel/lifespan.py
16501640
"""
16511641

16521642
from collections.abc import AsyncIterator
@@ -1761,8 +1751,7 @@ The lifespan API provides:
17611751

17621752
<!-- snippet-source examples/snippets/servers/lowlevel/basic.py -->
17631753
```python
1764-
"""
1765-
Run from the repository root:
1754+
"""Run from the repository root:
17661755
uv run examples/snippets/servers/lowlevel/basic.py
17671756
"""
17681757

@@ -1840,9 +1829,8 @@ The low-level server supports structured output for tools, allowing you to retur
18401829

18411830
<!-- snippet-source examples/snippets/servers/lowlevel/structured_output.py -->
18421831
```python
1843-
"""
1844-
Run from the repository root:
1845-
uv run examples/snippets/servers/lowlevel/structured_output.py
1832+
"""Run from the repository root:
1833+
uv run examples/snippets/servers/lowlevel/structured_output.py
18461834
"""
18471835

18481836
import asyncio
@@ -1943,9 +1931,8 @@ For full control over the response including the `_meta` field (for passing data
19431931

19441932
<!-- snippet-source examples/snippets/servers/lowlevel/direct_call_tool_result.py -->
19451933
```python
1946-
"""
1947-
Run from the repository root:
1948-
uv run examples/snippets/servers/lowlevel/direct_call_tool_result.py
1934+
"""Run from the repository root:
1935+
uv run examples/snippets/servers/lowlevel/direct_call_tool_result.py
19491936
"""
19501937

19511938
import asyncio
@@ -2023,9 +2010,7 @@ For servers that need to handle large datasets, the low-level server provides pa
20232010

20242011
<!-- snippet-source examples/snippets/servers/pagination_example.py -->
20252012
```python
2026-
"""
2027-
Example of implementing pagination with MCP server decorators.
2028-
"""
2013+
"""Example of implementing pagination with MCP server decorators."""
20292014

20302015
import mcp.types as types
20312016
from mcp.server.lowlevel import Server
@@ -2068,9 +2053,7 @@ _Full example: [examples/snippets/servers/pagination_example.py](https://github.
20682053

20692054
<!-- snippet-source examples/snippets/clients/pagination_client.py -->
20702055
```python
2071-
"""
2072-
Example of consuming paginated MCP endpoints from a client.
2073-
"""
2056+
"""Example of consuming paginated MCP endpoints from a client."""
20742057

20752058
import asyncio
20762059

@@ -2129,9 +2112,8 @@ The SDK provides a high-level client interface for connecting to MCP servers usi
21292112

21302113
<!-- snippet-source examples/snippets/clients/stdio_client.py -->
21312114
```python
2132-
"""
2133-
cd to the `examples/snippets/clients` directory and run:
2134-
uv run client
2115+
"""cd to the `examples/snippets/clients` directory and run:
2116+
uv run client
21352117
"""
21362118

21372119
import asyncio
@@ -2221,9 +2203,8 @@ Clients can also connect using [Streamable HTTP transport](https://modelcontextp
22212203

22222204
<!-- snippet-source examples/snippets/clients/streamable_basic.py -->
22232205
```python
2224-
"""
2225-
Run from the repository root:
2226-
uv run examples/snippets/clients/streamable_basic.py
2206+
"""Run from the repository root:
2207+
uv run examples/snippets/clients/streamable_basic.py
22272208
"""
22282209

22292210
import asyncio
@@ -2261,9 +2242,8 @@ When building MCP clients, the SDK provides utilities to help display human-read
22612242

22622243
<!-- snippet-source examples/snippets/clients/display_utilities.py -->
22632244
```python
2264-
"""
2265-
cd to the `examples/snippets` directory and run:
2266-
uv run display-utilities-client
2245+
"""cd to the `examples/snippets` directory and run:
2246+
uv run display-utilities-client
22672247
"""
22682248

22692249
import asyncio
@@ -2346,8 +2326,7 @@ The SDK includes [authorization support](https://modelcontextprotocol.io/specifi
23462326

23472327
<!-- snippet-source examples/snippets/clients/oauth_client.py -->
23482328
```python
2349-
"""
2350-
Before running, specify running MCP RS server URL.
2329+
"""Before running, specify running MCP RS server URL.
23512330
To spin up RS server locally, see
23522331
examples/servers/simple-auth/README.md
23532332

0 commit comments

Comments
 (0)