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
45 changed files with 452 additions and 925 deletions

View file

@ -1,6 +1,5 @@
#!/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.
It automatically handles OAuth flows without user interaction by programmatically
@ -89,8 +88,7 @@ class InMemoryTokenStorage(TokenStorage):
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.
This mimics the behavior of the TypeScript ConformanceOAuthProvider.
@ -101,8 +99,7 @@ class ConformanceOAuthCallbackHandler:
self._state: str | None = 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,
so we can capture it programmatically.
@ -148,8 +145,7 @@ class ConformanceOAuthCallbackHandler:
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:
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:
"""
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:
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:
"""
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:
1. Connects to the MCP server with OAuth client_credentials grant

View file

@ -1,6 +1,5 @@
#!/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.

View file

@ -1,5 +1,4 @@
"""
SSE Polling Demo Client
"""SSE Polling Demo Client
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.
"""

View file

@ -1,5 +1,4 @@
"""
FastMCP Desktop Example
"""FastMCP Desktop Example
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

View file

@ -1,6 +1,4 @@
"""
FastMCP Echo Server
"""
"""FastMCP Echo Server"""
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.
"""

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

View file

@ -4,8 +4,7 @@
# 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
similarity search.
"""

View file

@ -1,6 +1,4 @@
"""
FastMCP Example showing parameter descriptions
"""
"""FastMCP Example showing parameter descriptions"""
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.
"""
@ -15,8 +14,7 @@ mcp = FastMCP("Screenshot Demo")
@mcp.tool()
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.
"""
import pyautogui

View file

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

View file

@ -2,8 +2,7 @@
# 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/.

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.
"""
@ -10,8 +9,7 @@ mcp = FastMCP()
@mcp.tool(description="🌟 A tool that uses various Unicode characters in its description: á é í ó ú ñ 漢字 🎉")
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)
- Parameter defaults (CJK characters)
- 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
well-typed, validated data that clients can easily process.

View file

@ -1,6 +1,5 @@
#!/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.
"""

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.
Can be replaced with enterprise authorization servers like Auth0, Entra ID, etc.
@ -41,8 +40,7 @@ class AuthServerSettings(BaseModel):
class SimpleAuthProvider(SimpleOAuthProvider):
"""
Authorization Server provider with simple demo authentication.
"""Authorization Server provider with simple demo authentication.
This provider:
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
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
needing direct access to token storage.
@ -157,8 +154,7 @@ async def run_server(server_settings: AuthServerSettings, auth_settings: SimpleA
@click.command()
@click.option("--port", default=9000, help="Port to listen on")
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.

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.
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()
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
by OAuth authentication. User must be authenticated to access it.

View file

@ -1,5 +1,4 @@
"""
MCP Resource Server with Token Introspection.
"""MCP Resource Server with Token Introspection.
This server validates tokens via Authorization Server introspection and serves MCP resources.
Demonstrates RFC 9728 Protected Resource Metadata for AS/RS separation.
@ -47,8 +46,7 @@ class ResourceServerSettings(BaseSettings):
def create_resource_server(settings: ResourceServerSettings) -> FastMCP:
"""
Create MCP Resource Server with token introspection.
"""Create MCP Resource Server with token introspection.
This server:
1. Provides protected resource metadata (RFC 9728)
@ -80,8 +78,7 @@ def create_resource_server(settings: ResourceServerSettings) -> FastMCP:
@app.tool()
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
by OAuth authentication. User must be authenticated to access it.
@ -114,8 +111,7 @@ def create_resource_server(settings: ResourceServerSettings) -> FastMCP:
help="Enable RFC 8707 resource validation",
)
def main(port: int, auth_server: str, transport: Literal["sse", "streamable-http"], oauth_strict: bool) -> int:
"""
Run the MCP Resource Server.
"""Run the MCP Resource Server.
This server:
- Provides RFC 9728 Protected Resource Metadata

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