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

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

View file

@ -1,5 +1,4 @@
"""
Simple OAuth provider for MCP servers.
"""Simple OAuth provider for MCP servers.
This module contains a basic OAuth implementation using hardcoded user credentials
for demonstration purposes. No external authentication provider is required.
@ -47,8 +46,7 @@ class SimpleAuthSettings(BaseSettings):
class SimpleOAuthProvider(OAuthAuthorizationServerProvider[AuthorizationCode, RefreshToken, AccessToken]):
"""
Simple OAuth provider for demo purposes.
"""Simple OAuth provider for demo purposes.
This provider handles the OAuth flow by:
1. Providing a simple login form for demo credentials

View file

@ -1,5 +1,4 @@
"""
Simple MCP server demonstrating pagination for tools, resources, and prompts.
"""Simple MCP server demonstrating pagination for tools, resources, and prompts.
This example shows how to use the paginated decorators to handle large lists
of items that need to be split across multiple pages.

View file

@ -1,5 +1,4 @@
"""
In-memory event store for demonstrating resumability functionality.
"""In-memory event store for demonstrating resumability functionality.
This is a simple implementation intended for examples and testing,
not for production use where a persistent storage solution would be more appropriate.
@ -18,9 +17,7 @@ logger = logging.getLogger(__name__)
@dataclass
class EventEntry:
"""
Represents an event entry in the event store.
"""
"""Represents an event entry in the event store."""
event_id: EventId
stream_id: StreamId
@ -28,8 +25,7 @@ class EventEntry:
class InMemoryEventStore(EventStore):
"""
Simple in-memory implementation of the EventStore interface for resumability.
"""Simple in-memory implementation of the EventStore interface for resumability.
This is primarily intended for examples and testing, not for production use
where a persistent storage solution would be more appropriate.

View file

@ -1,5 +1,4 @@
"""
In-memory event store for demonstrating resumability functionality.
"""In-memory event store for demonstrating resumability functionality.
This is a simple implementation intended for examples and testing,
not for production use where a persistent storage solution would be more appropriate.
@ -26,8 +25,7 @@ class EventEntry:
class InMemoryEventStore(EventStore):
"""
Simple in-memory implementation of the EventStore interface for resumability.
"""Simple in-memory implementation of the EventStore interface for resumability.
This is primarily intended for examples and testing, not for production use
where a persistent storage solution would be more appropriate.

View file

@ -1,5 +1,4 @@
"""
SSE Polling Demo Server
"""SSE Polling Demo Server
Demonstrates the SSE polling pattern with close_sse_stream() for long-running tasks.

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3
"""
Example low-level MCP server demonstrating structured output support.
"""Example low-level MCP server demonstrating structured output support.
This example shows how to use the low-level server API to return
structured data from tools, with automatic validation against output
@ -49,9 +48,7 @@ async def list_tools() -> list[types.Tool]:
@server.call_tool()
async def call_tool(name: str, arguments: dict[str, Any]) -> Any:
"""
Handle tool call with structured output.
"""
"""Handle tool call with structured output."""
if name == "get_weather":
# city = arguments["city"] # Would be used with real weather API