duck.contrib.mcp.auth

Authentication module for MCP.

Module Contents

Classes

AuthResult

Return value expected from MCPView.authenticate(). allowed controls whether the connection is accepted at all; scopes controls what scope- gated tools/resources/prompts the caller can use - None means unrestricted (the default, i.e. no scope checking), an empty set/list means no scopes granted, anything else is checked as a subset by authorize().

API

class duck.contrib.mcp.auth.AuthResult(allowed: bool = True, scopes=None)[source]

Return value expected from MCPView.authenticate(). allowed controls whether the connection is accepted at all; scopes controls what scope- gated tools/resources/prompts the caller can use - None means unrestricted (the default, i.e. no scope checking), an empty set/list means no scopes granted, anything else is checked as a subset by authorize().

Initialization

classmethod deny()[source]

Shorthand for rejecting the connection outright.