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

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