Skip to content

Commit d41d0c0

Browse files
chore: add D212 lint rule to enforce Google-style docstrings (#1892)
1 parent df039bf commit d41d0c0

File tree

143 files changed

+452
-925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+452
-925
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

examples/clients/conformance-auth-client/mcp_conformance_auth_client/__init__.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
2-
"""
3-
MCP OAuth conformance test client.
2+
"""MCP OAuth conformance test client.
43
54
This client is designed to work with the MCP conformance test framework.
65
It automatically handles OAuth flows without user interaction by programmatically
@@ -89,8 +88,7 @@ async def set_client_info(self, client_info: OAuthClientInformationFull) -> None
8988

9089

9190
class ConformanceOAuthCallbackHandler:
92-
"""
93-
OAuth callback handler that automatically fetches the authorization URL
91+
"""OAuth callback handler that automatically fetches the authorization URL
9492
and extracts the auth code, without requiring user interaction.
9593
9694
This mimics the behavior of the TypeScript ConformanceOAuthProvider.
@@ -101,8 +99,7 @@ def __init__(self):
10199
self._state: str | None = None
102100

103101
async def handle_redirect(self, authorization_url: str) -> None:
104-
"""
105-
Fetch the authorization URL and extract the auth code from the redirect.
102+
"""Fetch the authorization URL and extract the auth code from the redirect.
106103
107104
The conformance test server returns a redirect with the auth code,
108105
so we can capture it programmatically.
@@ -148,8 +145,7 @@ async def handle_callback(self) -> tuple[str, str | None]:
148145

149146

150147
async def run_authorization_code_client(server_url: str) -> None:
151-
"""
152-
Run the conformance test client with authorization code flow.
148+
"""Run the conformance test client with authorization code flow.
153149
154150
This function:
155151
1. Connects to the MCP server with OAuth authorization code flow
@@ -180,8 +176,7 @@ async def run_authorization_code_client(server_url: str) -> None:
180176

181177

182178
async def run_client_credentials_jwt_client(server_url: str) -> None:
183-
"""
184-
Run the conformance test client with client credentials flow using private_key_jwt (SEP-1046).
179+
"""Run the conformance test client with client credentials flow using private_key_jwt (SEP-1046).
185180
186181
This function:
187182
1. Connects to the MCP server with OAuth client_credentials grant
@@ -223,8 +218,7 @@ async def run_client_credentials_jwt_client(server_url: str) -> None:
223218

224219

225220
async def run_client_credentials_basic_client(server_url: str) -> None:
226-
"""
227-
Run the conformance test client with client credentials flow using client_secret_basic.
221+
"""Run the conformance test client with client credentials flow using client_secret_basic.
228222
229223
This function:
230224
1. Connects to the MCP server with OAuth client_credentials grant

examples/clients/simple-auth-client/mcp_simple_auth_client/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
2-
"""
3-
Simple MCP client example with OAuth authentication support.
2+
"""Simple MCP client example with OAuth authentication support.
43
54
This client connects to an MCP server using streamable HTTP transport with OAuth.
65

examples/clients/sse-polling-client/mcp_sse_polling_client/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
SSE Polling Demo Client
1+
"""SSE Polling Demo Client
32
43
Demonstrates the client-side auto-reconnect for SSE polling pattern.
54

examples/fastmcp/complex_inputs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
FastMCP Complex inputs Example
1+
"""FastMCP Complex inputs Example
32
43
Demonstrates validation via pydantic with complex models.
54
"""

examples/fastmcp/desktop.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
FastMCP Desktop Example
1+
"""FastMCP Desktop Example
32
43
A simple example that exposes the desktop directory as a resource.
54
"""

examples/fastmcp/direct_call_tool_result_return.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
FastMCP Echo Server with direct CallToolResult return
3-
"""
1+
"""FastMCP Echo Server with direct CallToolResult return"""
42

53
from typing import Annotated
64

examples/fastmcp/echo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
FastMCP Echo Server
3-
"""
1+
"""FastMCP Echo Server"""
42

53
from mcp.server.fastmcp import FastMCP
64

examples/fastmcp/icons_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
FastMCP Icons Demo Server
1+
"""FastMCP Icons Demo Server
32
43
Demonstrates using icons with tools, resources, prompts, and implementation.
54
"""

examples/fastmcp/logging_and_progress.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
FastMCP Echo Server that sends log messages and progress updates to the client
3-
"""
1+
"""FastMCP Echo Server that sends log messages and progress updates to the client"""
42

53
import asyncio
64

0 commit comments

Comments
 (0)