chore: add D212 lint rule to enforce Google-style docstrings (#1892)

This commit is contained in:
Felix Weinberger 2026-01-16 16:10:52 +00:00 • committed by GitHub
commit d41d0c0128
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
143 changed files with 452 additions and 925 deletions

View file

@ -136,8 +136,7 @@ Let's create a simple MCP server that exposes a calculator tool and some data:
<!-- snippet-source examples/snippets/servers/fastmcp_quickstart.py --> <!-- snippet-source examples/snippets/servers/fastmcp_quickstart.py -->
```python ```python
""" """FastMCP quickstart example.
FastMCP quickstart example.
Run from the repository root: Run from the repository root:
uv run examples/snippets/servers/fastmcp_quickstart.py uv run examples/snippets/servers/fastmcp_quickstart.py
@ -727,8 +726,7 @@ Client usage:
<!-- snippet-source examples/snippets/clients/completion_client.py --> <!-- snippet-source examples/snippets/clients/completion_client.py -->
```python ```python
""" """cd to the `examples/snippets` directory and run:
cd to the `examples/snippets` directory and run:
uv run completion-client uv run completion-client
""" """
@ -1004,8 +1002,7 @@ MCP servers can use authentication by providing an implementation of the `TokenV
<!-- snippet-source examples/snippets/servers/oauth_server.py --> <!-- snippet-source examples/snippets/servers/oauth_server.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/servers/oauth_server.py uv run examples/snippets/servers/oauth_server.py
""" """
@ -1245,8 +1242,7 @@ Note that `uv run mcp run` or `uv run mcp dev` only supports server using FastMC
<!-- snippet-source examples/snippets/servers/streamable_config.py --> <!-- snippet-source examples/snippets/servers/streamable_config.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/servers/streamable_config.py uv run examples/snippets/servers/streamable_config.py
""" """
@ -1283,8 +1279,7 @@ You can mount multiple FastMCP servers in a Starlette application:
<!-- snippet-source examples/snippets/servers/streamable_starlette_mount.py --> <!-- snippet-source examples/snippets/servers/streamable_starlette_mount.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uvicorn examples.snippets.servers.streamable_starlette_mount:app --reload uvicorn examples.snippets.servers.streamable_starlette_mount:app --reload
""" """
@ -1394,8 +1389,7 @@ You can mount the StreamableHTTP server to an existing ASGI server using the `st
<!-- snippet-source examples/snippets/servers/streamable_http_basic_mounting.py --> <!-- snippet-source examples/snippets/servers/streamable_http_basic_mounting.py -->
```python ```python
""" """Basic example showing how to mount StreamableHTTP server in Starlette.
Basic example showing how to mount StreamableHTTP server in Starlette.
Run from the repository root: Run from the repository root:
uvicorn examples.snippets.servers.streamable_http_basic_mounting:app --reload 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
<!-- snippet-source examples/snippets/servers/streamable_http_host_mounting.py --> <!-- snippet-source examples/snippets/servers/streamable_http_host_mounting.py -->
```python ```python
""" """Example showing how to mount StreamableHTTP server using Host-based routing.
Example showing how to mount StreamableHTTP server using Host-based routing.
Run from the repository root: Run from the repository root:
uvicorn examples.snippets.servers.streamable_http_host_mounting:app --reload 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
<!-- snippet-source examples/snippets/servers/streamable_http_multiple_servers.py --> <!-- snippet-source examples/snippets/servers/streamable_http_multiple_servers.py -->
```python ```python
""" """Example showing how to mount multiple StreamableHTTP servers with path configuration.
Example showing how to mount multiple StreamableHTTP servers with path configuration.
Run from the repository root: Run from the repository root:
uvicorn examples.snippets.servers.streamable_http_multiple_servers:app --reload 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
<!-- snippet-source examples/snippets/servers/streamable_http_path_config.py --> <!-- snippet-source examples/snippets/servers/streamable_http_path_config.py -->
```python ```python
""" """Example showing path configuration when mounting FastMCP.
Example showing path configuration when mounting FastMCP.
Run from the repository root: Run from the repository root:
uvicorn examples.snippets.servers.streamable_http_path_config:app --reload uvicorn examples.snippets.servers.streamable_http_path_config:app --reload
@ -1644,8 +1635,7 @@ For more control, you can use the low-level server implementation directly. This
<!-- snippet-source examples/snippets/servers/lowlevel/lifespan.py --> <!-- snippet-source examples/snippets/servers/lowlevel/lifespan.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/servers/lowlevel/lifespan.py uv run examples/snippets/servers/lowlevel/lifespan.py
""" """
@ -1761,8 +1751,7 @@ The lifespan API provides:
<!-- snippet-source examples/snippets/servers/lowlevel/basic.py --> <!-- snippet-source examples/snippets/servers/lowlevel/basic.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/servers/lowlevel/basic.py uv run examples/snippets/servers/lowlevel/basic.py
""" """
@ -1840,8 +1829,7 @@ The low-level server supports structured output for tools, allowing you to retur
<!-- snippet-source examples/snippets/servers/lowlevel/structured_output.py --> <!-- snippet-source examples/snippets/servers/lowlevel/structured_output.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/servers/lowlevel/structured_output.py uv run examples/snippets/servers/lowlevel/structured_output.py
""" """
@ -1943,8 +1931,7 @@ For full control over the response including the `_meta` field (for passing data
<!-- snippet-source examples/snippets/servers/lowlevel/direct_call_tool_result.py --> <!-- snippet-source examples/snippets/servers/lowlevel/direct_call_tool_result.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/servers/lowlevel/direct_call_tool_result.py uv run examples/snippets/servers/lowlevel/direct_call_tool_result.py
""" """
@ -2023,9 +2010,7 @@ For servers that need to handle large datasets, the low-level server provides pa
<!-- snippet-source examples/snippets/servers/pagination_example.py --> <!-- snippet-source examples/snippets/servers/pagination_example.py -->
```python ```python
""" """Example of implementing pagination with MCP server decorators."""
Example of implementing pagination with MCP server decorators.
"""
import mcp.types as types import mcp.types as types
from mcp.server.lowlevel import Server from mcp.server.lowlevel import Server
@ -2068,9 +2053,7 @@ _Full example: [examples/snippets/servers/pagination_example.py](https://github.
<!-- snippet-source examples/snippets/clients/pagination_client.py --> <!-- snippet-source examples/snippets/clients/pagination_client.py -->
```python ```python
""" """Example of consuming paginated MCP endpoints from a client."""
Example of consuming paginated MCP endpoints from a client.
"""
import asyncio import asyncio
@ -2129,8 +2112,7 @@ The SDK provides a high-level client interface for connecting to MCP servers usi
<!-- snippet-source examples/snippets/clients/stdio_client.py --> <!-- snippet-source examples/snippets/clients/stdio_client.py -->
```python ```python
""" """cd to the `examples/snippets/clients` directory and run:
cd to the `examples/snippets/clients` directory and run:
uv run client uv run client
""" """
@ -2221,8 +2203,7 @@ Clients can also connect using [Streamable HTTP transport](https://modelcontextp
<!-- snippet-source examples/snippets/clients/streamable_basic.py --> <!-- snippet-source examples/snippets/clients/streamable_basic.py -->
```python ```python
""" """Run from the repository root:
Run from the repository root:
uv run examples/snippets/clients/streamable_basic.py uv run examples/snippets/clients/streamable_basic.py
""" """
@ -2261,8 +2242,7 @@ When building MCP clients, the SDK provides utilities to help display human-read
<!-- snippet-source examples/snippets/clients/display_utilities.py --> <!-- snippet-source examples/snippets/clients/display_utilities.py -->
```python ```python
""" """cd to the `examples/snippets` directory and run:
cd to the `examples/snippets` directory and run:
uv run display-utilities-client uv run display-utilities-client
""" """
@ -2346,8 +2326,7 @@ The SDK includes [authorization support](https://modelcontextprotocol.io/specifi
<!-- snippet-source examples/snippets/clients/oauth_client.py --> <!-- snippet-source examples/snippets/clients/oauth_client.py -->
```python ```python
""" """Before running, specify running MCP RS server URL.
Before running, specify running MCP RS server URL.
To spin up RS server locally, see To spin up RS server locally, see
examples/servers/simple-auth/README.md examples/servers/simple-auth/README.md

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """MCP OAuth conformance test client.
MCP OAuth conformance test client.
This client is designed to work with the MCP conformance test framework. This client is designed to work with the MCP conformance test framework.
It automatically handles OAuth flows without user interaction by programmatically It automatically handles OAuth flows without user interaction by programmatically
@ -89,8 +88,7 @@ class InMemoryTokenStorage(TokenStorage):
class ConformanceOAuthCallbackHandler: class ConformanceOAuthCallbackHandler:
""" """OAuth callback handler that automatically fetches the authorization URL
OAuth callback handler that automatically fetches the authorization URL
and extracts the auth code, without requiring user interaction. and extracts the auth code, without requiring user interaction.
This mimics the behavior of the TypeScript ConformanceOAuthProvider. This mimics the behavior of the TypeScript ConformanceOAuthProvider.
@ -101,8 +99,7 @@ class ConformanceOAuthCallbackHandler:
self._state: str | None = None self._state: str | None = None
async def handle_redirect(self, authorization_url: str) -> None: async def handle_redirect(self, authorization_url: str) -> None:
""" """Fetch the authorization URL and extract the auth code from the redirect.
Fetch the authorization URL and extract the auth code from the redirect.
The conformance test server returns a redirect with the auth code, The conformance test server returns a redirect with the auth code,
so we can capture it programmatically. so we can capture it programmatically.
@ -148,8 +145,7 @@ class ConformanceOAuthCallbackHandler:
async def run_authorization_code_client(server_url: str) -> None: async def run_authorization_code_client(server_url: str) -> None:
""" """Run the conformance test client with authorization code flow.
Run the conformance test client with authorization code flow.
This function: This function:
1. Connects to the MCP server with OAuth authorization code flow 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:
async def run_client_credentials_jwt_client(server_url: str) -> None: async def run_client_credentials_jwt_client(server_url: str) -> None:
""" """Run the conformance test client with client credentials flow using private_key_jwt (SEP-1046).
Run the conformance test client with client credentials flow using private_key_jwt (SEP-1046).
This function: This function:
1. Connects to the MCP server with OAuth client_credentials grant 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:
async def run_client_credentials_basic_client(server_url: str) -> None: async def run_client_credentials_basic_client(server_url: str) -> None:
""" """Run the conformance test client with client credentials flow using client_secret_basic.
Run the conformance test client with client credentials flow using client_secret_basic.
This function: This function:
1. Connects to the MCP server with OAuth client_credentials grant 1. Connects to the MCP server with OAuth client_credentials grant

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """Simple MCP client example with OAuth authentication support.
Simple MCP client example with OAuth authentication support.
This client connects to an MCP server using streamable HTTP transport with OAuth. This client connects to an MCP server using streamable HTTP transport with OAuth.

View file

@ -1,5 +1,4 @@
""" """SSE Polling Demo Client
SSE Polling Demo Client
Demonstrates the client-side auto-reconnect for SSE polling pattern. Demonstrates the client-side auto-reconnect for SSE polling pattern.

View file

@ -1,5 +1,4 @@
""" """FastMCP Complex inputs Example
FastMCP Complex inputs Example
Demonstrates validation via pydantic with complex models. Demonstrates validation via pydantic with complex models.
""" """

View file

@ -1,5 +1,4 @@
""" """FastMCP Desktop Example
FastMCP Desktop Example
A simple example that exposes the desktop directory as a resource. A simple example that exposes the desktop directory as a resource.
""" """

View file

@ -1,6 +1,4 @@
""" """FastMCP Echo Server with direct CallToolResult return"""
FastMCP Echo Server with direct CallToolResult return
"""
from typing import Annotated from typing import Annotated

View file

@ -1,6 +1,4 @@
""" """FastMCP Echo Server"""
FastMCP Echo Server
"""
from mcp.server.fastmcp import FastMCP from mcp.server.fastmcp import FastMCP

View file

@ -1,5 +1,4 @@
""" """FastMCP Icons Demo Server
FastMCP Icons Demo Server
Demonstrates using icons with tools, resources, prompts, and implementation. Demonstrates using icons with tools, resources, prompts, and implementation.
""" """

View file

@ -1,6 +1,4 @@
""" """FastMCP Echo Server that sends log messages and progress updates to the client"""
FastMCP Echo Server that sends log messages and progress updates to the client
"""
import asyncio import asyncio

View file

@ -4,8 +4,7 @@
# uv pip install 'pydantic-ai-slim[openai]' asyncpg numpy pgvector # uv pip install 'pydantic-ai-slim[openai]' asyncpg numpy pgvector
""" """Recursive memory system inspired by the human brain's clustering of memories.
Recursive memory system inspired by the human brain's clustering of memories.
Uses OpenAI's 'text-embedding-3-small' model and pgvector for efficient Uses OpenAI's 'text-embedding-3-small' model and pgvector for efficient
similarity search. similarity search.
""" """

View file

@ -1,6 +1,4 @@
""" """FastMCP Example showing parameter descriptions"""
FastMCP Example showing parameter descriptions
"""
from pydantic import Field from pydantic import Field

View file

@ -1,5 +1,4 @@
""" """FastMCP Screenshot Example
FastMCP Screenshot Example
Give Claude a tool to capture and view screenshots. Give Claude a tool to capture and view screenshots.
""" """
@ -15,8 +14,7 @@ mcp = FastMCP("Screenshot Demo")
@mcp.tool() @mcp.tool()
def take_screenshot() -> Image: def take_screenshot() -> Image:
""" """Take a screenshot of the user's screen and return it as an image. Use
Take a screenshot of the user's screen and return it as an image. Use
this tool anytime the user wants you to look at something they're doing. this tool anytime the user wants you to look at something they're doing.
""" """
import pyautogui import pyautogui

View file

@ -1,6 +1,4 @@
""" """FastMCP Echo Server"""
FastMCP Echo Server
"""
from mcp.server.fastmcp import FastMCP from mcp.server.fastmcp import FastMCP

View file

@ -2,8 +2,7 @@
# dependencies = [] # dependencies = []
# /// # ///
""" """FastMCP Text Me Server
FastMCP Text Me Server
-------------------------------- --------------------------------
This defines a simple FastMCP server that sends a text message to a phone number via https://surgemsg.com/. This defines a simple FastMCP server that sends a text message to a phone number via https://surgemsg.com/.

View file

@ -1,5 +1,4 @@
""" """Example FastMCP server that uses Unicode characters in various places to help test
Example FastMCP server that uses Unicode characters in various places to help test
Unicode handling in tools and inspectors. Unicode handling in tools and inspectors.
""" """
@ -10,8 +9,7 @@ mcp = FastMCP()
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: á é í ó ú ñ 漢字 🎉") @mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: á é í ó ú ñ 漢字 🎉")
def hello_unicode(name: str = "世界", greeting: str = "¡Hola") -> str: def hello_unicode(name: str = "世界", greeting: str = "¡Hola") -> str:
""" """A simple tool that demonstrates Unicode handling in:
A simple tool that demonstrates Unicode handling in:
- Tool description (emojis, accents, CJK characters) - Tool description (emojis, accents, CJK characters)
- Parameter defaults (CJK characters) - Parameter defaults (CJK characters)
- Return values (Spanish punctuation, emojis) - Return values (Spanish punctuation, emojis)

View file

@ -1,5 +1,4 @@
""" """FastMCP Weather Example with Structured Output
FastMCP Weather Example with Structured Output
Demonstrates how to use structured output with tools to return Demonstrates how to use structured output with tools to return
well-typed, validated data that clients can easily process. well-typed, validated data that clients can easily process.

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """MCP Everything Server - Conformance Test Server
MCP Everything Server - Conformance Test Server
Server implementing all MCP features for conformance testing based on Conformance Server Specification. Server implementing all MCP features for conformance testing based on Conformance Server Specification.
""" """

View file

@ -1,5 +1,4 @@
""" """Authorization Server for MCP Split Demo.
Authorization Server for MCP Split Demo.
This server handles OAuth flows, client registration, and token issuance. This server handles OAuth flows, client registration, and token issuance.
Can be replaced with enterprise authorization servers like Auth0, Entra ID, etc. Can be replaced with enterprise authorization servers like Auth0, Entra ID, etc.
@ -41,8 +40,7 @@ class AuthServerSettings(BaseModel):
class SimpleAuthProvider(SimpleOAuthProvider): class SimpleAuthProvider(SimpleOAuthProvider):
""" """Authorization Server provider with simple demo authentication.
Authorization Server provider with simple demo authentication.
This provider: This provider:
1. Issues MCP tokens after simple credential authentication 1. Issues MCP tokens after simple credential authentication
@ -98,8 +96,7 @@ def create_authorization_server(server_settings: AuthServerSettings, auth_settin
# Add token introspection endpoint (RFC 7662) for Resource Servers # Add token introspection endpoint (RFC 7662) for Resource Servers
async def introspect_handler(request: Request) -> Response: async def introspect_handler(request: Request) -> Response:
""" """Token introspection endpoint for Resource Servers.
Token introspection endpoint for Resource Servers.
Resource Servers call this endpoint to validate tokens without Resource Servers call this endpoint to validate tokens without
needing direct access to token storage. needing direct access to token storage.
@ -157,8 +154,7 @@ async def run_server(server_settings: AuthServerSettings, auth_settings: SimpleA
@click.command() @click.command()
@click.option("--port", default=9000, help="Port to listen on") @click.option("--port", default=9000, help="Port to listen on")
def main(port: int) -> int: def main(port: int) -> int:
""" """Run the MCP Authorization Server.
Run the MCP Authorization Server.
This server handles OAuth flows and can be used by multiple Resource Servers. This server handles OAuth flows and can be used by multiple Resource Servers.

View file

@ -1,5 +1,4 @@
""" """Legacy Combined Authorization Server + Resource Server for MCP.
Legacy Combined Authorization Server + Resource Server for MCP.
This server implements the old spec where MCP servers could act as both AS and RS. This server implements the old spec where MCP servers could act as both AS and RS.
Used for backwards compatibility testing with the new split AS/RS architecture. Used for backwards compatibility testing with the new split AS/RS architecture.
@ -87,8 +86,7 @@ def create_simple_mcp_server(server_settings: ServerSettings, auth_settings: Sim
@app.tool() @app.tool()
async def get_time() -> dict[str, Any]: async def get_time() -> dict[str, Any]:
""" """Get the current server time.
Get the current server time.
This tool demonstrates that system information can be protected This tool demonstrates that system information can be protected
by OAuth authentication. User must be authenticated to access it. by OAuth authentication. User must be authenticated to access it.

Some files were not shown because too many files have changed in this diff Show more